Hide field unless user id is one of x, y, z

SOLVED

There is a field that people should be able to complete when adding a new company, but not able to change / view when on the change menu unless they are one of four people.

We thought an On Change script would work for this and have tried the below, however it does not hide the field (and my user ID isn't in that list).

if (user_userid == "38,27,28,32")
{
crm.fields("comp_agent").show();
}
else
{
crm.fields("comp_agent").hide();
}

Can anyone help?

Thanks
Sarah

Parents
  • 0

    No reason why Pauls version using "User" shouldn't work.... or you could use  CurrentUser

    var userid = CurrentUser.user_userid;
    if (Values("Act")=="201")
    {
    if (!(userid==27 || userid==28 || userid==32 || userid==38))
    {
    Hidden=true;
    }
    }

    if you are still struggling, I would ask your business partner for help.

  • 0 in reply to Sean from Spire

    Hi Sean

    I’m dealing with a similar requirement: Make ReadOnly all fields on OpportunityDetailBox for several users if oppo_stage is closed.

    I know your solution work for sure:

    var userid = CurrentUser.user_userid;
    if (Values("Act")=="523"  && Values(Oppo_status ==”Closed”)){
       if (!(userid==27 || userid==28 || userid==32 || userid==38)){
          ReadOnly =true;
       }
    }

    But have to put this script on the create script of every field and have 20+ fields on screen, so this is hard to maintain after.

    Did you know any way to do it with all fields on screen with a single script?

Reply
  • 0 in reply to Sean from Spire

    Hi Sean

    I’m dealing with a similar requirement: Make ReadOnly all fields on OpportunityDetailBox for several users if oppo_stage is closed.

    I know your solution work for sure:

    var userid = CurrentUser.user_userid;
    if (Values("Act")=="523"  && Values(Oppo_status ==”Closed”)){
       if (!(userid==27 || userid==28 || userid==32 || userid==38)){
          ReadOnly =true;
       }
    }

    But have to put this script on the create script of every field and have 20+ fields on screen, so this is hard to maintain after.

    Did you know any way to do it with all fields on screen with a single script?

Children