in catalog form i will keep the values form sla (contract_sla) table, but it will not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:02 AM
in catalog form i need to keep the values form sla (contract_sla) table, i need the duration type and duration value and keep in service portal form, but it will not working.
based on company field (reference - core_company)
and Target- Response, resolution, Response To Site ( choice field)
i will get duration type and duration filed value and set it in the form.
any one help me,
this is the script i tried but it will not entering into the contract_sla table,
Script incude:
-----------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:28 AM - edited 03-19-2024 05:49 AM
You haven't shared if you are receiving any of the logs in the Script Include. You don't need the first GlideRecord in the Script Include since you're passing in a sys_id from a reference variable on the core_company table, you know it is valid as long as it is received into the Script Include. You should always return something, this will help troubleshooting. Your logs should have a unique and common prefix so you can easily search through the voluminous system log to find them, if they exist. Your if(gr.next()) condition is never met as gr is undefined. The below code will get you closer, assuming your u_company custom field on the contract_sla table is a reference to core_company, and the slatype variable value matches the target field value, which you can confirm from the logs. The duration field value will be a seemingly meaningless number, so you may need to do something with it before returning it to the client to get it in the format you're looking for in the variable value assignment.
getSLA: function() {
gs.log('SI running');
var answer = '';
var company = this.getParameter('sysparm_company');
var slatype = this.getParameter('sysparm_sla');
gs.log('SI company ' + company);
gs.log('SI slatype ' + slatype);
var sla = new GlideRecord('contract_sla');
sla.addQuery('u_company', company);
sla.addQuery('target', slatype);
//sla.addQuery('name','Adidas_Break_Fix_Triage_P4');
//sla.groupBy('target');
sla.query();
if (sla.next()) {
gs.log('SI contract found ' + sla.name
answer = sla.duration;
}
return answer;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 07:32 AM
Hi @Brad Bowman ,
in sla table (contract_sla), it will not returning any log.
log is coming in comany (core_company ) table, that's it after it not returning any log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 07:59 AM
That would be expected with your original script, given the if(gr.next()) error. Let me know the results of my proposed script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 11:27 PM