SBX - Search With Button

SBX - Forum Post Title

Dynamics 365 Portal - Validation with Logged In User

Microsoft Dynamics CRM Forum

Study And Work asked a question on 12 Dec 2017 1:40 AM

Question Status

Suggested Answer

Hi, 

I have created a Page called Vehicle  in dynamics 365 portal. I have a field Approval status. I need to hide the field based on the Logged in User. Any one please provide the steps to achieve this scenario? 

Thanks in advance.

Reply
Moly Omidvar responded on 12 Dec 2017 1:48 AM
My Badges
Suggested Answer

I do something like this:

1- Create 2 pages, one with Approval field and the other without that. (page A and page B)

2- Create web rol for every web page. (Ex. Page A and page B)

3- Give to users with web rol A  for Page A and for the other is B.

Also, your question is not clear. There is other ways to achieve that.

Reply
Ravi Kashyap responded on 12 Dec 2017 1:50 AM
Suggested Answer

Hi,

You would need to write some JavaScript to achieve this. Basically first get the logged in user and then show/ hide the field.

Here are some links which will help you-

dynamicscrmcoe.com/pass-a-logged-in-user-adxstudio-portal-wcf-service

arpitmscrmhunt.blogspot.com.au/.../field-validations-adxstudio-and-crm.html

rajeevpentyala.com/.../useful-jscript-syntaxes-adx-portal

Hope this helps.

Reply
Study And Work responded on 13 Dec 2017 1:07 AM

I am looking for the JavaScript code to get the logged in User.I can see many blogs saying use Liquids to get the Logged in User. But how to get the value in java script for further validations.

Thanks.

Reply
Ravi Kashyap responded on 13 Dec 2017 1:10 AM

Hi,

The above shared inks contains details about how to get it in JavaScript. Please check.

Reply
Arpit Shrivastava responded on 13 Dec 2017 7:52 AM
My Badges
Suggested Answer

Use below code under custom javascript:

$(document).ready(function(){

// To get loggedin user guid

var username = '{{ user.Id }}';

// To get loggedin user name

var username = '{{ user.fullname}}';

// To check loggedin user webrole

{% if user.roles contains 'ABC'%}

// Write your hide/show logic

{% else if user.roles contains 'PQR'%}

// Write your hide/show logic

});

Mark as verified, if it solves your problem.

Cheers

Arpit

Reply
pavan sai chippa responded on 7 Feb 2019 8:37 AM

Hi,

You can use below scripts

window["Microsoft"].Dynamic365.Portal.User.contactId - For Contact ID

window["Microsoft"].Dynamic365.Portal.User.userName - For UserName

By using contactID , you can have a ODATA call to contact entity and do necessary.

Hope it helps you.

Reply
Moly Omidvar responded on 12 Dec 2017 1:48 AM
My Badges
Suggested Answer

I do something like this:

1- Create 2 pages, one with Approval field and the other without that. (page A and page B)

2- Create web rol for every web page. (Ex. Page A and page B)

3- Give to users with web rol A  for Page A and for the other is B.

Also, your question is not clear. There is other ways to achieve that.

Reply
Ravi Kashyap responded on 12 Dec 2017 1:50 AM
Suggested Answer

Hi,

You would need to write some JavaScript to achieve this. Basically first get the logged in user and then show/ hide the field.

Here are some links which will help you-

dynamicscrmcoe.com/pass-a-logged-in-user-adxstudio-portal-wcf-service

arpitmscrmhunt.blogspot.com.au/.../field-validations-adxstudio-and-crm.html

rajeevpentyala.com/.../useful-jscript-syntaxes-adx-portal

Hope this helps.

Reply
Arpit Shrivastava responded on 13 Dec 2017 7:52 AM
My Badges
Suggested Answer

Use below code under custom javascript:

$(document).ready(function(){

// To get loggedin user guid

var username = '{{ user.Id }}';

// To get loggedin user name

var username = '{{ user.fullname}}';

// To check loggedin user webrole

{% if user.roles contains 'ABC'%}

// Write your hide/show logic

{% else if user.roles contains 'PQR'%}

// Write your hide/show logic

});

Mark as verified, if it solves your problem.

Cheers

Arpit

Reply

SBX - Two Col Forum

SBX - Migrated JS