Record is getting populated in servicenow widget customization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2024 09:02 AM
i am using two widget from 1st widget i am calling the 2 nd widget
1st widget :calling the second widget and want to pass some paramter(it is actually a value) using this code ,
now the problem is when i showing info message i am getting the same value as a type string ,and using that in the var instanceid ,the particular record is not opening,showing you are not authorized or record is not valid
but when i am putting it as hardcoded value then it is taking the value correctly and populating the record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 05:34 AM
Hello @abhi56
Since you are already getting the sys_id in 2nd widget, try this:
gs.addInfoMessage("Options instance: " + options.instance);
var instanceId = options.instance;
gs.addInfoMessage("Instance ID: " + instanceId);
if (instanceId) {
// Retrieve the record here using the instanceId
var record = new GlideRecord('your_table');
if (record.get(instanceId)) {
gs.addInfoMessage("Record retrieved: " + record.getValue("sys_id"));
} else {
gs.addInfoMessage("Record not found or invalid.");
}
} else {
gs.addInfoMessage("Instance ID is not valid.");
}
There is another concept broadcast and rootscope to pass data from one widget to another.
You can refer this video to understand more about it: broadcast and rootscope
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar