How to get CI service owner and requester's manager as approver in workflow approval activity

srikanth241
Mega Expert

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.

find_real_file.png

Any suggestion or code assistance will help me a lot.

thanks

PlatformDeveloper CommunityDeveloper CommunityDiscussDevelopCommunity Corner

1 ACCEPTED SOLUTION

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);


  }


  }


}


View solution in original post

12 REPLIES 12

Instead of retrieving the record from cmdb_ci in your script, retrieve it from cmdb_ci_appl and you'll have your field available and value populated.


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);


  }


  }


}


Glad you go it working. Thanks for sharing the final solution. Happy to help.