Jars
08/29/2024, 9:11 AMCeligo AI
08/29/2024, 9:12 AMAI generated answer (using internal Slack threads):To make an HTTPS request asynchronous in a UserEvent script, you can use the
https.post.promise(options)
method. However, it's important to note that server-side promises in SuiteScript run synchronously, meaning each individual script will wait for all processing to complete before continuing.
Here is a sample code snippet for making an asynchronous HTTPS request:
javascript
var myHeaders = {
'Content-Type': 'application/json'
};
var myPayload = {
"recordType": "customer",
"id": "123"
};
https.post.promise({
url: '<https://my-endpoint-url>',
headers: myHeaders,
body: myPayload
})
.then(function(response){
log.debug({
title: 'Response',
details: response.body
});
})
.catch(function onRejected(reason){
log.debug({
title: 'Rejected Promise',
details: reason
});
});
In this example, the https.post.promise(options)
method returns a promise that is fulfilled with the HTTP response. The then
method is used to specify what to do when the promise is fulfilled, and the catch
method is used to specify what to do if the promise is rejected.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
08/29/2024, 9:12 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.798965514
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.7939291
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.793850899
Celigo AI
08/29/2024, 9:12 AM