Only recent value is coming in logs in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 08:27 AM
Hi All,
We have created a custom table u_projects in which we have below fields:
1. Name- String
2. Account- reference to customer_account table
3. Auto escalate to development - True/ False
In another table extended to Case table called Project Case we are adding a custom field called Project Name(u_project_number) reference to u_projects table and Escalate to development(True/ False)
The requirement is when Auto escalate to development is checked in u_projects table , Escalate to development should checked while inserting the Project Case.
I have written a script include and calling that in BR.
Script Include:
var getProjectValue = Class.create();
getProjectValue.prototype = {
initialize: function() {
},
getProjects: function() {
var project = new GlideRecord('x_bnxt_proj_case_table');
project.addEncodedQuery('active=true');
project.query();
if (project.next()) {
var acc = project.account;
var projectName = project.u_project_number;
gs.log("Project SysID " + projectName);
//gs.log("Account Name " + acc);
var gr = new GlideRecord("u_projects");
gr.addEncodedQuery("u_account=" + acc);
gr.addEncodedQuery("sys_id=" + projectName );
gr.query();
if (gr.next()) {
if (gr.u_auto_escalate == true) {
return true;
} else {
return false;
}
} else {
return false;
}
}
},
type: 'getProjectValue'
};
Business Rule:
var grs = new getProjectValue();
var returnVal = grs.getProjects();
current.escalate_to_development= returnVal;
gs.log("Accounts returnVal " + returnVal);
Everthing was working fine untill we found that in the u_projects table if we have two account with the same name then script is checking only for the 1st record.
For example:
In the above screenshot, two records have same account name and Auto escalate to development is true for one and false for another. Still it is taking the record which is created first.
Please help
Thanks,
Sam
- Labels:
-
Customer Service Management