Hello @channel , I'm currently working on a NetSu...
# general
b
Hello @channel , I'm currently working on a NetSuite WMS project and I've hit a roadblock. I need to store the response from a RESTlet into the state within a mobile action. My RESTlet is set up and returning the expected result, but I'm unsure how to capture this response in the mobile action's state for later use. The RESTlet returns a simple object
{ mypo: result }
, and I've set up an output parameter in the mobile action. However, the step to actually store this response in the state is where I'm struggling. I've reviewed the documentation and tried to configure the action accordingly, but I'm missing something. If anyone has experience with this process or can offer some insight into what I may be doing wrong, your help would be greatly appreciated. Thank you!
j
Brekk - After making the RESTlet call, include a SuiteScript step to handle the response. Extract relevant data from the answer and store it in the mobile action's state. E.g. /** * SuiteScript 2.0 code snippet to handle RESTlet response and store in the mobile action state. */ /** * @NApiVersion 2.x * @NScriptType Suitelet */ define(['N/record', 'N/log', 'N/https', 'N/url'], function(record, log, https, url) { function onRequest(context) { // Make a RESTlet call var restletUrl = 'https://<ACCOUNT_ID>.suitetalk.api.netsuite.com/app/site/hosting/restlet.nl?script=<SCRIPT_ID>&deploy=<DEPLOYMENT_ID>'; var response = https.get({ url: restletUrl }); // Extract data from the RESTlet response var responseData = response.body; // Adjust this based on the actual structure of your response // Store the data in the mobile action state var mobileAction = context.request.parameters.mobileAction; // Adjust this based on the actual parameter name var state = context.request.parameters.state; // Adjust this based on the actual parameter name // Store the response data in the state state.myCustomData = responseData; // Adjust this based on the actual structure of your response context.response.write('RESTlet response stored in state.'); } return { onRequest: onRequest }; } );
👀 1
r
Even I am stuck on this problem. Any luck @BIVEK KUMAR SHAH. I am damn sure that we need output parameters on the action but I still don't see anything in the state. I just don't see how the above logic will help with our problem. @Jose Sanchez-Capo Do you mind explaining the steps?