- 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-09-2017 07:54 AM
You will need to check the "Advanced" checkbox on the approval activity which will expose a script field that you can use to set these approvals.
answer = [];
answer.push(current.requested_for.manager);
if (!gs.nil(current.cmdb_ci.owned_by)) {
answer.push(current.cmdb_ci.service_owner);
} else if (!gs.nil(current.cmdb_ci.service_category_owner) {
answer.push(current.cmdb_ci.service_category_owner);
} else {
answer.push(current.cmdb_ci.service_executive);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2017 08:30 AM
Hi Michael,
Thanks for your response.
How do current.cmdb_ci.service_category_owner or current.cmdb_ci.service_executive or current.cmdb_ci.service_owner will be pulled to workflow approval activity as we are getting ci name in a variable called application in catalog Item. how does system knows that we are pointing to particular ci stored in Variable. Please let me know.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2017 08:41 AM
OK thanks for the clarification, I assumed you were setting the request item's CI to that. So if they are from a variable, change the script to:
answer = [];
answer.push(current.requested_for.manager);
if (!gs.nil(current.variables.application.owned_by)) {
answer.push(current.variables.application.service_owner);
} else if (!gs.nil(current.variables.application.service_category_owner) {
answer.push(current.variables.application.service_category_owner);
} else {
answer.push(current.variables.application.service_executive);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 04:23 AM
Hi Michael ,
answer = [];
answer.push(current.requested_for.manager);
if (!gs.nil(current.variables.application.owned_by)) {
answer.push(current.variables.application.service_owner);
} else if (!gs.nil(current.variables.application.service_category_owner) {
answer.push(current.variables.application.service_category_owner);
} else {
answer.push(current.variables.application.service_executive);
}
the code which you have given is not working...
even I tried this code
I am able to get manager but I am not able to get Service owner.
var answer = [];
answer.push(getManager());// This is working
answer.push(getServiceOwner());
function getManager(){
var user = new GlideRecord('sys_user');
if (user.get(current.variables.employee_name)) {
goTroughHirearchy(user);
//goTroughHirearchy(user) is function which is getting user value
}
function getServiceOwner(){
gs.log("nithin");//This log is coming
var user = new GlideRecord('cmdb_ci');
user.get(current.variables.application);
if (!gs.nil(user.managed_by)) {
gs.log("NT" + user.managed_by );//this log is not coming
answer.push(user.managed_by);
} else if (!gs.nil(user.owned_by)) {
answer.push(user.owned_by);
gs.log("NT1" + user.owned_by );// this log is not coming
} else {
answer.push(user.u_service_executive);
gs.log("NT2" + user.u_service_executive );// this log is not coming
}
}
Any Suggestion or help
Thanks.