Hello – I hope someone could provide some advise or feedback.
Summary: I am trying to create a custom button (UE script) on Sales Order record. That custom button executes a function from a client side script. The function (snippet below) uses https.post.promise. It calls a Suitelet that I will be using to process some backend logic.
Problem: The “.then” portion is not called/executed.
Notes:
- Everything is working expect for .then part. The suitelet is called by the post
- When I tried to call the same function on pageInit, the .then part is executing
- I have used chrome’s javascript profiler as well and tried to compare both executions (by clicking button and pageInit). I can see that .then is being called when the snippet is executed via pageInit but is not executed, when clicking the button
function createIntercoPo(soId){ log.debug('CS - Create Interco PO', 'START ' + soId); var suiteletURL = url.resolveScript({ scriptId: 'customscript_swx_sl_auto_ic_so_po', deploymentId: 'customdeploy_swx_sl_auto_ic_so_po', }); log.debug('CS - Suitelet URL', suiteletURL); /*https.post({ async: true, url: suiteletURL, body: { soId: soId }, callback: function(response) { var result = JSON.parse(response.body); redirectAfterProcess(result, transId, transType, "generation"); } });*/ https.post.promise({ url: suiteletURL, body: { soId: soId } }) .then(function (response){ log.debug({ title: 'Response', details: response }); //redirectAfterProcess(soId); log.debug('CS - Inside Promise', 'Test'); }) .catch(function onRejected(reason) { log.debug({ title: 'Invalid Request: ', details: reason }); }); log.debug('CS - Create Interco PO', 'END'); }