Hello
I need to disable a field on a form using JS if a current user isn't member of some specific team.
I wrote this code:
Hello
I need to disable a field on a form using JS if a current user isn't member of some specific team.
I wrote this code:
I had problems with xml and didn't use encodeURIComponent :)
Now it works correctly. Thank you!
Hi,
If you want to construct fetch xml in the form of fetchxml2 and use ${currentUserId}, you can refer to my code:
function disableField(executionContext){ var formContext = executionContext.getFormContext(); var currentUserId = Xrm.Utility.getGlobalContext().userSettings.userId; var name = "lisi"; var fetchXML = ` `; fetchXML = "?fetchXml=" encodeURIComponent(fetchXML); Xrm.WebApi.retrieveMultipleRecords("account", fetchXML).then( function success(result) { if(result.entities.length > 0){ alert("success:" result.entities); }else{ alert("none"); } }, function (error) { console.log(error.message); alert(error.message); } ); }
Regarding the conditional statement not being executed, you can check the following three points:
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... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156