- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2015 06:39 AM
Hi,
I have tried using following code in my Scheduled Job (SJ) to call REST Message in a scoped application.
var r = new sn_ws.RESTMessageV2('x_snc_all_time_car.All Surf SN TimeCard', 'get');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parser = new JSONParser();
var parsed = parser.parse(responseBody);
It gives a warning and SJ doesn't get executed at all:
java.lang.SecurityException: JSONParser undefined, maybe missing global qualifier
Then I tried amending with global as below:
var r = new sn_ws.RESTMessageV2('x_snc_all_time_car.All Surf SN TimeCard', 'get');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parser = new global.JSONParser();
var parsed = parser.parse(responseBody);
It gives a warning and SJ doesn't get executed at all:
org.mozilla.javascript.EcmaError: The undefined value has no properties.
Anyone have any idea to handle with this?
Thanks,
Yogesh More
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2015 06:57 AM
Hi Yogesh,
Please follow the below steps and let me know the outcome.
Go to the script include->Search for JSONParser->Now make sure the field "accessible from" is set to "All application scopes". OOB this is set to be "this application scope only".
Please find the screenshot attached for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2015 11:42 AM
Hi Yogesh,
I am not sure what steps you have taken to get to the point where you are now.
You mention you want to invoke from a scheduled job a RESTMessageV2 from a scoped context.
Have you verified that the RESTMessageV2 you create works as expected in an un-scoped context?
Then moved on to check it works as expected in a scoped context?
Having done that, you are now seeking to invoke from a scheduled job?
Best Regards,
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2015 01:55 AM
Hi Tony,
Thanks for looking into it.
Yes, it works as expected without any issue from Scripts-Background run in Global scope.
And now I want that to be scheduled.
Thanks,
Yogesh More

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2015 06:57 AM
Hi Yogesh,
Please follow the below steps and let me know the outcome.
Go to the script include->Search for JSONParser->Now make sure the field "accessible from" is set to "All application scopes". OOB this is set to be "this application scope only".
Please find the screenshot attached for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2015 08:30 AM
Hi Pradeep,
Yes, I had checked it but I did not want to change OOB Script Include.
However, I have achieved it changing my code in following way:
gs.include("global.JSON"); |
var r = new sn_ws.RESTMessageV2('x_snc_all_time_car.All Surf SN Deployments', 'get');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var json = new global.JSON();
var parsed = json.decode(responseBody);
This worked for me.
Thanks anyway for your response! Marking it as Correct Answer.
Regards,
Yogesh More