- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 04:02 AM
Hi All,
I am trying to access display business rule scratchpad values into catalog client script but it always shows undefined. Can anyone help here. I think there is some minor mistake.
Actually there is a record producer to create an incident. Whenever the incident is created via the record producer, it will automatically assigned to service desk. But there I am trying to build one exclude condition.
Like if particular ci is selected, the it should go to "Team A Group" instead service desk . Only for that particular condition the assignment group should changed. There is a hidden reference variable in the record producer to do this. The hidden field is "assignment_group". So in the catalog client script i am trying to call the scratchpad and set the value but the scratchpad value shows undefined always. Am i doing any mistake here?
Is there anyway that scratchpad value to be called and used in catalog client script?
Display business rule on "Incident" Form :
Catalog Client Script which tried to call the scratchpad on :
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 06:00 AM
Hi,
Script Include: It should be client callable
var GetProperty = Class.create();
GetProperty.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDetail: function(){
return gs.getProperty('propertyName1') + '@' + gs.getProperty('propertyName2');
},
type: 'GetProperty'
});
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('GetProperty');
ga.addParam('sysparm_name', "getDetail");
ga.getXMLAnswer(function(answer){
if(answer != ''){
var propertyValue1 = answer.split('@')[0];
var propertyValue2 = answer.split('@')[1];
// now compare
}
});
//Type appropriate comment here, and begin script below
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 05:43 AM
Hi Brad,
So in that case, If I change my BR table to sc_cat_item_producer then it will show onchange of the form?
Ideally i wants to set the assignment_group value onchange of the ci in form. Once submitted it will be mapped in incident assignment group and description field. So to set the producer.assignment group for my case, is there any way?
Because we have some other logic behind this assignment group. That is the reason I am just doing some if condition do make this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 05:05 AM
Hi Rani,
Few things to check
1) Your BR should be of type Display -> ensure this
2) Why to use Catalog Client Script? You should be using normal client script on incident table
3) Is your catalog client script running on the Target record
-> Applies on Target Record should be checked
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 05:45 AM
Hi Ankur,
Yes I have created display BR only. Since its should be autopoluate the assignment group value in catalog form itself. so that is the reason I am using catalog client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 05:49 AM
Ideally, as per best practice, I don't wants to use hard coded sys ids in catalog client script. Instead of hard coding the sys id ,in any other way if those sys ids accessible in catalog client script then my purpose will solve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2021 05:57 AM
Hi,
Not possible to use g_scratchpad from Display BR to Catalog Client Script
Please use GlideAjax in your Catalog client script and then return the sys_id of group
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader