web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

D365 Portal: Cannot limit optionset based on logged-in User

(0) ShareShare
ReportReport
Posted on by 15

Hello All!

I am trying to limit the optionset values inside of a Create form in my Dynamics 365 Portal based on the user that is logged in. I am able to get the following JavaScript code to work in my Organization CRM by loading a JavaScript web resource to a form (picture below) and checking the "Pass execution context as first parameter", but this will do nothing when I load the same form in my D365 Portal. 

Web-Resource.JPG

JS Code:

function LimitLocationBySeller(executionContext) {

var formContext = executionContext.getFormContext();
formContext.getControl('new_location').removeOption('100000005');

}

After researching online, I don't think this is working because I am not passing in the ExecutionContext into the Portal form. This is easy to do in a regular form since I just need to check the "Pass execution context as first parameter" box, but how do reference the ExecutionContext in the portal? I am currently adding the JS to the "Custom Javascript" field on the Entity Form I want this to occur on (pictured below). I would appreciate any help on this!

Entity-Form.JPG

Thank you everyone!

I have the same question (0)
  • Suggested answer
    Nicholas Hayduk Profile Picture
    2,863 on at

    Portals doesn't support the same JavaScript you'd use on your forms in the CRM.

    You'll probably need to use a combination of Liquid and JavaScript within the "Custom JavaScript" field on the Entity Form.  The inputs on a Portals form have the ID set to the logical name of the attribute.  So, using jQuery, you can target the dropdown using something like $('#new_location').  Then use Liquid to get the details of the current user to determine which options should be removed.

    Hope that helps.

    Nick

  • kimd32 Profile Picture
    15 on at

    I'll give that a try, I'll reply back aftewards!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
11manish Profile Picture

11manish 92

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans