web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Prajwal Bhetwal,

    You have created 3 duplicate posts. Please delete them.

    Thanks,

    Girish S.

  • Prajwal Bhetwal Profile Picture
    65 on at

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

  • GirishS Profile Picture
    27,827 Moderator on at

    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.

  • Suggested answer
    Amira Beldjilali Profile Picture
    on at

    Hello,

    You need to get the value of the attribute to compare

    docs.microsoft.com/.../getvalue

    Regards,

    Amira

  • Suggested answer
    Community Member Profile Picture
    on at

    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)
    		}
    	}
    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans