cancel
Showing results for 
Search instead for 
Did you mean: 

XBO based on User role.

Former Member
0 Kudos

Hi Everyone

I have extended an Xbo "Customer" with the following element "UI field".

element TCDataLocked : Indicator = false;

The use case is that once the UI field is selected the "Other fields" on the UI will get locked (Read only). it is achieved using binding in "Adjust properties" operation.

This function is working perfect but now I want this UI field to be executed only by some users e.g. Managers.

I am struggling to come up with required AfterModify script. Please any guidance will be greatly appreciated.

kind regards

Asad

Accepted Solutions (1)

Accepted Solutions (1)

former_member200567
Active Contributor
0 Kudos

Hi Asad,

You need to use another Indicator field for TCDataLocked .

element isManager:Indicator;

var identity = Identity.Retrieve(Context.GetCurrentIdentityUUID());

var occupationCode=identity.Person.CurrentCommon.Person.OccupationCode.GetDescription();

if(occupationCode=="Manager")

{

     this.isManager=true;

}else{

     this.isManager=false;

}

Hope this helps.

Fred.

Former Member
0 Kudos

Hi Fred

Thank you fro your help and I have added the new field to XBO and once I used your script in Aftermodify the error message come with that "Identifier IsManger" doesn't exist.

Any Idea?

Regards

Asad

former_member200567
Active Contributor
0 Kudos

Hi, Asad

     Did you add IsManager indicator field to your XBO definition?

businessobject Customer{    

     element IsManager:Indicator;

}

Save and Activate.

Hope this helps.

Fred.

Former Member
0 Kudos

Hi Fred

Thanks for your reply.

Yes I did. Buts still show the errors.

Regards

Asad

former_member200567
Active Contributor
0 Kudos

Hi, Asad

     Which node exactly did you add IsManager to?

     And in which node's aftermodify event did you write your code?

Regards,

Fred.

Former Member
0 Kudos

Hi Fred

Yes silly from me. the element was added to common node and script at root node.

I have changed it and it has compile now but when I Test it it does allow my business user to make changes even though its not Manager.

Thank you

Regards

Asad

former_member200567
Active Contributor
0 Kudos

Hi, Asad.

This code, actually, I did not test it myself.

var occupationCode=identity.Person.CurrentCommon.Person.OccupationCode.GetDescription();

Can you test it and display in some test field?

Can you find out what the occupation code for the current user in debugging or using some dummy field?

Hope this helps.

Fred.

Former Member
0 Kudos

Hi Fred

Yes its work now it doesn't allow me to save once the script is there and I am able to save it without the script.

it works perfect thank a lot for your patience and efforts.

Regards

Asad

former_member200567
Active Contributor
0 Kudos

Glad that I could help.

Fred.

Answers (1)

Answers (1)

Former Member
0 Kudos

Check out this:

Former Member
0 Kudos

Hi Alessandro

Thanks for your reply I am aware of the UI switches and at least the ones for Standard fields. But I was looking for one about "Non Standard use" and your blog about that is really useful. I will be trying it very soon.

For this current issue our customer wants this field to be based on some script and since I don't have a lot of experience here I have posted this question. I need some script help here. thank you

Regards

Asad