- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2017 06:59 AM
Hi All,
How to get CI service owner and requester's manager as approvers in workflow approval activity for a catalog Item.
Catalog Item has application variable which captures CI's and employee variable for requester.
If CI's service owner is missing then it should check for service category owner , if that is also blank then it should check Service Executive. All these are fields in cmdb_ci table.
Any suggestion or code assistance will help me a lot.
thanks
PlatformDeveloper CommunityDeveloper CommunityDiscussDevelopCommunity Corner
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 07:55 AM
Thanks Chuck! It's working
Here is the final code!
function getServiceOwner(){
var user = new GlideRecord('cmdb_ci_appl');
if(user.get(current.variables.application)){
if (!user.managed_by.nil()) {
//gs.log("manger" + user.managed_by );
answer.push(user.managed_by);
} else if (!user.owned_by.nil()) {
answer.push(user.owned_by);
//gs.log("owner" + user.owned_by );
} else {
answer.push(user.u_service_executive);
//gs.log("service owner" + user.u_service_executive);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 05:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 05:58 AM
In your getServiceOwner() function, double check the value of current.variables.application to ensure it's not empty/null. Your user.get() may be failing and you don't know it.
Example:
if (! current.variables.application) {
gs.log('No application specified');
return;
}
if (!user.get(current.variables.application)) {
gs.log('uh-oh, no application retrieved for: ' + current.variables.application);
return;
}
// Now you can look at getting at the user-dot properties here...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 06:20 AM
Hello Chuck,
Thanks for your response.
Now I am getting log as NT2 undefined.
NT2undefined |
Which means as it is reference field in CI table should I need to use getDisplay value..? or is there any mistake in my code..?
user.u_service_executive;
user.u_service_executive
My function:
function getServiceOwner(){
gs.log("nithin");
var user = new GlideRecord('cmdb_ci');
if(user.get(current.variables.application)){
if (!user.managed_by.nil()) {
gs.log("NT" + user.managed_by );
answer.push(user.managed_by);
} else if (!user.owned_by.nil()) {
answer.push(user.owned_by);
gs.log("NT1" + user.owned_by );
} else {
answer.push(user.u_service_executive);
gs.log("NT2" + user.u_service_executive );
}
}
}
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 06:36 AM
This sounds like the u_service_executive field may be on a sub-class of cmdb_ci and not on cmdb_ci directly. Check the dictionary entry for that field to determine which field it is on. This is a common mistake on hierarchical tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 07:18 AM