Inbound Integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 03:51 AM
Hi all,
I tried to executed this code by following the steps mentioned from the learn path in servicenow.
The expected outcome is to generate the city based on IP but its not generating
BR:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 08:45 PM
@abjaffrey You can make sure below steps with avoiding using variable outside of try block and remove duplicate catch block,
You're passing current.ip_address as a string parameter to the REST Message. If the ip_address field is empty, this could result in an undefined value being sent.
Correctly validate the current.ip_address before using it.
responseBody is declared within the try block but used outside it, potentially causing an error if the try block fails.
There’s a second catch(err) block after the main code, which is syntactically incorrect.
Avoid calling current.update() within a synchronous Business Rule. It can cause recursion and performance issues.
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 10:13 PM
When i run the script below, im getting the city value in BG scripts.
try {
var r = new sn_ws.RESTMessageV2('x_1582528_iplookup.IPInfo', 'GetIPInfo');
r.setStringParameterNoEscape('specific_field', 'city');
r.setStringParameterNoEscape('ipaddress', '8.8.8.8');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.message;
}
//var responseObj = JSON.parse(responseBody);
//current.city = responseObj.city;
gs.info(responseBody);
//gs.info('City = ' + current.city);
//current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 10:30 PM
Hi @abjaffrey
Update the following code line in the BR.
Query -> BR running on which table and what is trigger condition?
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 02:52 AM
Not working,
The BR is running on a custom created table with 2 fields where if we enter the ip and submit the city field should be filled.
its an async with update & Insert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 03:01 AM
im able to print responseObj.city but the value is not getting assigned in the city fields