Run groovy script as another user

Sam Huawey
Contributor
September 28, 2023

I have a groovy script in Post Function for one of workflows in ServiceDesk. It creates objects in Assets. I found out that these assets are created by the user that performs transition. 

Is it possible to perform this task as another user? We have a special service account in ServiceDesk called Automate.

I create assets using code like this:


 

def objectTypeRecord = objectTypeFacade.loadObjectTypeBean(8);

/* Create a new unsaved object bean */
def objectBean = objectTypeRecord.createMutableObjectBean();

/* Set up the attribute list */
def attrBeans = new ArrayList();

// .....

objectBean.setObjectAttributeBeans(attrBeans);
objectBean = objectFacade.storeObjectBean(objectBean);

1 answer

1 vote
Sam Huawey
Contributor
September 28, 2023

As an alternative I can use REST API and provide a token of Automate account, but it would be nice to stay inside groovy.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events