Make Attachments available only for specific groups

danielgiurgiu
Tera Expert

Hy all, 

I am struggling in UI builder and in UX Screen Condition to make the attachment SNC Screen not to be visible for incidents where assignment group has the "external" type (created by me). 

I have tried in condition builder but here I did not find how to do a query on the incident table.

 

I tried creating a new Ux Screen Condition but it seems that the script does not take the parameters table and sysID.

Even a simple check :

(function checkScreenVisibility(params) {  
    alert(params.table);
    if (params.table == 'incident')
    return false ;
    else
    return true ;

})(inputProperties);
is not providing the desired results.
If somebody has encountered this issue please help with a solution
2 ACCEPTED SOLUTIONS

Rajesh Chopade1
Mega Sage

Hi @danielgiurgiu 

Check following script and do the needful changes and try:

    // Check if the current record is an incident
    if (params.table !== 'incident') {
        return true; // Show screen for non-incident records
    }

    // Query the incident record to get the assignment group
    var incidentGr = new GlideRecord('incident');
    if (incidentGr.get(params.sysId)) {
        var assignmentGroupId = incidentGr.getValue('assignment_group');

        // Query the assignment group to get its type
        var groupGr = new GlideRecord('sys_user_group');
        if (groupGr.get(assignmentGroupId)) {
            var groupType = groupGr.getValue('u_type'); // Assuming 'u_type' is the custom field

            if (groupType === 'external') {
                return false; // Hide screen if the group type is 'external'
            }
        }
    }

    return true; // Show screen by default

I hope my answer helps you to resolve your issue, if yes mark my answer helpful & correct.

Thank you

View solution in original post

Thank you for the script, the problem was that I did not map the parameters correctly in the UX screen condition and incident and sysID were not passed to the code:

{
"type": "MAP_CONTAINER",
"container": {
"table": {
"type": "DATA_OUTPUT_BINDING",
"binding": {
"address": [
"sowrecordctrl",
"table"
]
}
},
"sysId": {
"type": "DATA_OUTPUT_BINDING",
"binding": {
"address": [
"sowrecordctrl",
"sysId"
]
}
}
}
}

after I put this code in Parameter Mapping it worked

View solution in original post

3 REPLIES 3

Rajesh Chopade1
Mega Sage

Hi @danielgiurgiu 

Check following script and do the needful changes and try:

    // Check if the current record is an incident
    if (params.table !== 'incident') {
        return true; // Show screen for non-incident records
    }

    // Query the incident record to get the assignment group
    var incidentGr = new GlideRecord('incident');
    if (incidentGr.get(params.sysId)) {
        var assignmentGroupId = incidentGr.getValue('assignment_group');

        // Query the assignment group to get its type
        var groupGr = new GlideRecord('sys_user_group');
        if (groupGr.get(assignmentGroupId)) {
            var groupType = groupGr.getValue('u_type'); // Assuming 'u_type' is the custom field

            if (groupType === 'external') {
                return false; // Hide screen if the group type is 'external'
            }
        }
    }

    return true; // Show screen by default

I hope my answer helps you to resolve your issue, if yes mark my answer helpful & correct.

Thank you

Thank you for the script, the problem was that I did not map the parameters correctly in the UX screen condition and incident and sysID were not passed to the code:

{
"type": "MAP_CONTAINER",
"container": {
"table": {
"type": "DATA_OUTPUT_BINDING",
"binding": {
"address": [
"sowrecordctrl",
"table"
]
}
},
"sysId": {
"type": "DATA_OUTPUT_BINDING",
"binding": {
"address": [
"sowrecordctrl",
"sysId"
]
}
}
}
}

after I put this code in Parameter Mapping it worked

Hi,

i'm trying to use your code for my purpose: i got a custom table on hr agent workspace, and need to hide the attachment paperclip for new records (sys_id=-1): any advice?

 

Thanks in advace