Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Form customisation

(0) ShareShare
ReportReport
Posted on by 65

Hi,

I'm adding a JS to the CRM form that should do 3 things: 

1. Should hide an option set value (180560002) while creating a new record. 

2. Should hide option set value from the existing record if the option set value != 180560002, to prevent users from updating it to that option.

3. Should show the option set value if the record already exists in CRM for value = 180560002.

Currently, my JS is doing the first two things correctly but it is also clearing the option set value from the record that already exists with contact type = 180560002

pastedimage1663301041235v1.png

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Form customisation

    Hi Prajwal Bhetwal,

    Amira Beldjilali's answer is correct.

    To get a field's value, please use formContext.getAttribute("boq_contacttype").getValue();

    attribute.getValue (Client API reference) - Power Apps | Microsoft Docs

    So your code should be like this:

    function removeOption(executionContext)
    {
    	var formContext = executionContext.getFormContext();
    	var contacttype = formContext.getControl("boq_contacttype");
    	var contacttypevalue = formContext.getAttribute("boq_contacttype").getValue();
    	var formtype = formContext.getFormType();
    	
    	if(formtype == 1){
    		contacttype.removeOption(180560002);
    	}else if(formtype == 2 || formtype == 3){
    		if(contacttypevalue != 180560002){
    			contacttype.removeOption(180560002)
    		}
    	}
    }

  • Suggested answer
    Amira Beldjilali Profile Picture
    on at
    RE: Form customisation

    Hello,

    You need to get the value of the attribute to compare

    docs.microsoft.com/.../getvalue

    Regards,

    Amira

  • GirishS Profile Picture
    27,823 Moderator on at
    RE: Form customisation

    You can only delete a post you made if there has been no reply. So keep this post and delete remaining 3 other posts.

    Thanks,

    Girish S.

  • Prajwal Bhetwal Profile Picture
    65 on at
    RE: Form customisation

    under action I can only see edit and report.. how do i delete it?

  • GirishS Profile Picture
    27,823 Moderator on at
    RE: Form customisation

    Hi Prajwal Bhetwal,

    You have created 3 duplicate posts. Please delete them.

    Thanks,

    Girish S.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,925 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans