system name appearing while approving/rejecting via portal view in csm case

Hafsa1
Mega Sage

while approving the record in case while viewing from portal view "system" name is coming instead of username who approve the approval record. when can be the issue?

Hafsa1_0-1750400648528.png

 

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Hafsa1 

is this happening with all the cases?

Did you customize that ticket page?

It's working fine for me

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

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @Hafsa1 ,

Check if you have logged in as admin and approving.

try with other user and approve the record.

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

Hafsa1
Mega Sage

i'm inpersonated as user and then approving.

Yes I have customized the widget. have added one more state "need more info". it is happening when i'm using this button .

server script:

---

(function() {
    data.actionPreventedMsg = gs.getMessage("Update failed");
    var gr = $sp.getRecord();
    if (gr == null || !gr.isValid()) {
        data.isValid = false;
        return;
    }

    data.isValid = true;
    data.isMine = new global.ApprovalDelegationUtil().isMyApproval(gr);
    //data.userWriteAccess = gs.hasRole("sn_customerservice.customer");
    data.userWriteAccess = gs.hasRole("sn_customerservice.case_viewer");


    var approverDisplay = gr.approver.getDisplayValue();
    if (!data.isMine && approverDisplay)
        data.approverDisplay = approverDisplay;

    if (approverDisplay) {
        data.approvedMsg = gs.getMessage("Approved by {0}", approverDisplay);
        data.rejectedMsg = gs.getMessage("Rejected by {0}", approverDisplay);
        data.moreinfoMsg = gs.getMessage("Asked for more information by {0}", approverDisplay);
    } else {
        data.approvedMsg = gs.getMessage("Approved");
        data.rejectedMsg = gs.getMessage("Rejected");
        data.moreinfoMsg = gs.getMessage("Asked for more information");
    }
    if (input && data.isMine && data.userWriteAccess && input.comment && (input.op == 'approved' || input.op == 'rejected')) {
        //if (input && input.op && data.isMine && data.userWriteAccess && input.comment) {
        gr.state = input.op;
        gr.comments = input.comment;
        data.updateID = gr.update();
        if (GlideStringUtil.nil(data.updateID)) {
            // update failed so fetch again for correct values
            gr = $sp.getRecord();
        }
        data.op = "";
    }
    if (input && data.isMine && data.userWriteAccess && input.comment && input.op == 'more_info_required') {
        //if (input && input.op && data.isMine && data.userWriteAccess && input.comment) {
        gr.state = input.op;
        //gr.comments = approverDisplay + " needs more information for this task to be approved." + "\n\n" + input.comment;
        gr.comments.setJournalEntry(approverDisplay + " needs more information for this task to be approved." + "\n\n" + input.comment, gs.getUserName());
        data.updateID = gr.update();
        if (GlideStringUtil.nil(data.updateID)) {
            // update failed so fetch again for correct values
            gr = $sp.getRecord();
        }
        data.op = "";
    }
    //
    //if (input && input.comment){
    //   gr.comments = input.comment;
    //   gr.update();
    //}
    //
    var fields = $sp.getFields(gr, 'state,sys_created_on');

    if (gr.sys_mod_count > 0)
        fields.push($sp.getField(gr, 'sys_updated_on'));

    data.fields = fields;
    data.state = gr.state.toString();
    data.sys_updated_on = gr.sys_updated_on.toString();
    data.sys_id = gr.getUniqueValue();
    data.table = gr.getTableName();
    data.label = getRecordBeingApproved(gr).getLabel();
    data.esignature = {
        username: gs.getUserName(),
        userSysId: gs.getUserID(),
        e_sig_required: checkESig(gr)
    };

 
    data.result = '8no';
    //gs.log("TEST id-"+gr.sysapproval); = id of case record
    //gs.log("TEST id2-"+data.sys_id); = id of approving record
    var gr3 = new GlideRecord("sn_customerservice_north_america_procurement");
    gr3.addQuery("sys_id", gr.sysapproval);
    gr3.addEncodedQuery("subcategory=333^ORsubcategory=250^ORsubcategory=58^ORsubcategory=26^ORsubcategory=50");
    gr3.query();
    if (gr3.next()) {
        data.result = '8yes';
    }
 

    function checkESig(approvalGR) {
        var esigRegistryGR = new GlideRecord("e_signature_registry");
        if (!esigRegistryGR.isValid())
            return false;

        var table = approvalGR.getValue("source_table");
        if (!table)
            table = approvalGR.sysapproval.sys_class_name;
        if (!table)
            return false;

        esigRegistryGR.addQuery("enabled", "true");
        esigRegistryGR.addQuery("table_name", table);
        esigRegistryGR.query();
        return esigRegistryGR.hasNext();
    }

    function getRecordBeingApproved(gr) {
        if (!gr.sysapproval.nil())
            return gr.sysapproval.getRefRecord();

        return gr.document_id.getRefRecord();
    }
})();
----

@Hafsa1 

is this happening with all the cases?

Is it always showing system user when non-admin is checking?

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