Not able to update catalog task state using custon ui action by end user

Sharath807
Tera Contributor

I created a custom ui action in sc_task form with some logics,  including updating the state field to closed complete on clicking it. But it works as expected if the user has admin role. But when agents( who has no admin role) clicks other logics are working but state is not getting closed completed in sc task form. Any help?

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

@Sharath807 

what debugging did you do?

share the UI action config screenshots and any error thrown for non-admins?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sharath807
Tera Contributor

@Ankur Bawiskar Hi Thanks for reply
Below is part of script in ui action:

 var grAsset = new GlideRecord('alm_asset');
    if (grAsset.get(current.u_asset + '')) {
        gs.log("@@@@@@@@@@@@@");
        if (current.request_item.cat_item == 'xxx') { // request for a computer
            // if (current.request_item.cat_item == 'xxx') {
            //alert('in');
            gs.log("66666");
            var date_time = gs.nowDateTime();
            grAsset.assigned_to = current.request.requested_for;
            grAsset.owned_by = ownedBy; /*To put condition once confirmed*/
            grAsset.install_status = 1;
            grAsset.substatus = '';
            grAsset.assigned = date_time;
            grAsset.asset_function = current.request_item.variables.asset_type;
            grAsset.work_notes = "Asset has been allocated to user as per " + current.request_item.number;
           
            grAsset.update();
            var grTask = new GlideRecord('sc_task');
            if (grTask.get(current.sys_id)) {
                grTask.state = 3;
                grTask.work_notes = "Asset allocated and task closed";
                grTask.update();
            } else {
                gs.log("Failed to update task: Record not found");
            }
            gs.addInfoMessage('Asset <b>' + current.u_asset.display_name + '</b> allocated successfully to <b>' + current.request.requested_for.name + '</b>');

@Sharath807 

so which log came?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sharath807
Tera Contributor

@Ankur Bawiskar  This log popup 

gs.addInfoMessage('Asset <b>' + current.u_asset.display_name + '</b> allocated successfully to <b>' + current.request.requested_for.name + '</b>');
But state is not updating