I want make source is phone default for particular groups

Talari Balateja
Tera Expert

Hi,

 

When monitoring team & delivery team members are creating security incident then source should be "phone" by default. it should restrict others to create a source is phone.  

 

EX:

I'm member of monitoring team and I'm creating security incident after click on new button then source should be phone for me and for others it should be none.

 

Regards,

Sanju

2 ACCEPTED SOLUTIONS

@abhishekdalvi 

 

it's showing error, even the part of that particular group and after that I added myself as user from that particular group. then it's working fine but for the existed users it's not working. I'm I created function in right way? why it's showing error like this.

 

 

EXISTING USERS:

TalariBalateja_0-1712208696975.png

 

FOR ME:

TalariBalateja_1-1712208880326.png

 

 

CLIENT SCRIPT:

function onLoad() {

var sysid = g_user.userID; //get current user sysid
var ga = new GlideAjax('sn_si.CheckUserGroup'); //script include name
ga.addParam('sysparm_name', 'getgroup'); //function name
ga.addParam('sysparm_name_sysid', sysid); //passing sysid to server
ga.getXMLAnswer(getGroup);
function getGroup(response) {
if (response == 'true') {
g_form.addInfoMessage('Part of group');
g_form.setValue('contact_type','dlp');
g_form.setReadOnly('contact_type',true); // If you want to restrict the field from changing value
} else {
g_form.addInfoMessage(response);
g_form.addInfoMessage('Not Part of group');
g_form.setValue('contact_type', '');//Keep blank
g_form.setReadOnly('contact_type',true); // If you want to restrict the field from changing value
}
}
}

 

SCRIPT INCLUDE:

var CheckUserGroup = Class.create();
CheckUserGroup.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
       getgroup: function() {
var usersysid = this.getParameter('sysparm_name_sysid');//getting usersysid from client
        var mem = new GlideRecord("sys_user_grmember");
mem.addEncodedQuery('user='+ usersysid+'^group=53a2232a97dc71d047f0b147f053af44^ORgroup=961b73ee47d471d0de549f97536d4300'); // Replace your group sys id in this query
        mem.query();
        if (mem.next()) {
            return true;
        } else {
            return false;
        }
    },
 
    type: 'CheckUserGroup'
});
 
 
FUNTION GET GROUP:
 
TalariBalateja_2-1712208983170.png

 

 

View solution in original post

Hi @Talari Balateja ,

Script is taking the login user. Please try after impersonating the user who is present in that group.

Impersonating an user will solve your issue.

 

Thanks!

Regards,
Abhishek Dalvi

View solution in original post

16 REPLIES 16

Dipen Wadhwana
Giga Guru

Hi @Talari Balateja ,

Please try this:

Step 1: Create a display Business rule with script as. Place the below script between function templates in script body.

g_scratchpad.grp = gs.getUser().isMemberOf('PASS GROUP NAME HERE');  


Now update the client script as

function onLoad() {
    if (g_scratchpad.grp) {
        g_form.setValue('contact_type ', 'phone');
    } else {
        g_form.setValue('contact_type ', '');
    }
}

Please mark this response as helpful if your question has been answered correctly.

abhishekdalvi
Tera Guru

Hi @Talari Balateja ,

 

Can you try the same with below syntax in your script include 2nd line.

CheckUserGroup.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

 

Thank you!

Regards,
Abhishek Dalvi