-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_restApiResponse.js
71 lines (55 loc) · 2.2 KB
/
fetch_restApiResponse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
apex.message.confirm("工事確定処理を行いますか?", function( okPressed ) {
apex.jQuery("#t_Alert_Notification").remove();
if( okPressed ) {
//var id = apex.item("P4_BYH_ODRNO").getValue();
//var strUrl='http://129.150.177.100/SB_PO_PurchaseOrder/PurchaseOrderRS?id=' + id;
//alert(strUrl);
//apex.item("P28_URL").setValue(strUrl);
//window.open().location.href=strUrl.close();
var id = apex.item("P4_BYH_ODRNO").getValue();
//alert(id);
//var strUrl='http://129.150.177.100/SB_PO_PurchaseOrder/PurchaseOrderRS?id=' + id;
var strUrl='http://localhost:7101/SB_PO_PurchaseOrder/PurchaseOrderRS?id=XB3648284850'
var outMsg = '';
fetch(strUrl,{
method: 'GET',
mode: 'cors',
headers: new Headers({'Accept': 'application/xml'})
})
.then(function(response) {
return response.text()
}).then(function(xmlData) {
let parser = new DOMParser();
let xmlDoc = parser.parseFromString(xmlData, "text/xml");
let status = xmlDoc.querySelector("Success").textContent;
let msg = xmlDoc.querySelector("Message").textContent;
if(status==='true'){
outMsg += msg + "\n" ;
var odrNumber = '';
var els = xmlDoc.querySelectorAll('OrderNumber');
for (var i=0, l=els.length; i<l; i++) {
var el = els[i].textContent;
odrNumber += el + "\n" ;
//console.log(odrNumber);
};
outMsg += odrNumber;
//console.log(outMsg);
apex.message.alert(outMsg);
}else{
let errCode = xmlDoc.querySelector("errorCode").textContent;
outMsg += ":" + errCode;
//console.log(outMsg);
apex.message.alert(outMsg);
// alert のOKボタン押下を待つ
apex.jQuery(document.activeElement).bind('click', function () {
apex.submit('btn_kakutei');
return true;
});
};
}).catch(function(e) {
//console.log("PurchaseOrderRS Is Error");
apex.message.alert("PurchaseOrderRS Is Error");
});
} else{
}
});