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
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)
}
}
}
Hello,
You need to get the value of the attribute to compare
docs.microsoft.com/.../getvalue
Regards,
Amira
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.
under action I can only see edit and report.. how do i delete it?
Hi Prajwal Bhetwal,
You have created 3 duplicate posts. Please delete them.
Thanks,
Girish S.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,275 Most Valuable Professional
nmaenpaa 101,156