Announcements
Hi,
I'm looking at creating a Form (New Contact) which will display different fields / requirements depending on the Business Unit it is assigned to. I already have a New Contact form for an existing Business Unit that I don't want to remove
I've looked at older blogs Business Unit Specific Custom Forms - Microsoft Dynamics CRM Forum Community Forum but I'm still having issues?
I've carried out the steps mentioned in the above post.
New Security Role - Contact Form (Veterans Members Only)
New Business Unit created - Veterans Services
Created a New Form
Assigned the New from to the Security Role
Ok and even published the customizations
Assigned myself the Security role, but I'm still seeing the existing New contact Form??
What Security permission would I need to give?
Currently these are them
Yes Please.
I am happy to help you.
Have a good time.
Hi,
I think it works??
It's asking for the last name as soon as the New button is selected but that's not a bad thing....
Did have some issues when closed the app down and re-opened ???
I'll give it a bit more testing but thank you for all your help. If I do have any further issues with this, will it be ok to reach out to you again??
Yes. Please copy new one and Pass execution context during function call as shown below:
Hi,
Changed the function description
Now get an error (Error log provided) I have saved and published
So not confuse this error was for the previous code not the one you have recently updated..
Can I just copy this new one it to the Form Libraries with the edit function??
Hi,
Please call function as shown below:
and updated the code little:
function getAssignedTeam(executionContext) { var formContext=executionContext.getFormContext(); var userSettings = Xrm.Utility.getGlobalContext().userSettings; var currentUserId=userSettings.userId; var fetchXML="?fetchXml=" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; Xrm.WebApi.retrieveMultipleRecords("team", fetchXML).then( function success(result) { var lookupValue = new Array(); lookupValue[0] = new Object(); lookupValue[0].id = result.entities[0].teamid; lookupValue[0].name = result.entities[0].name; lookupValue[0].entityType = "team"; formContext.getAttribute("ownerid").setValue(lookupValue); formContext.data.entity.save(); }, function (error) { console.log(error.message); // handle error conditions } ); }
Hi,
Sorry should have mentioned, I've done those steps
But my name still appears as the Owner??
In above code you do not have to change anything.
You need to create one js. file and add them as webresource in dynamic crm.
After that go to contact form and under form editor you will find form properties there you can register onload event and in onload call above function as described below
www.tutorialspoint.com/.../microsoft_crm_jscript_web_resources.htm
Hi,
Sorry if I'm being a bit naïve here but I'm assuming it's like any script, I work a little with PowerApps you I will need to change some of the script?
Such as these attribute names??
"<attribute name='name'/>"+
"<attribute name='businessunitid'/>"+
"<attribute name='teamid'/>"+
"<attribute name='teamtype'/>"+
"<order attribute='name' descending='false'/>"+
Hi,
Please use below code on form load.
function getAssignedTeam(executionContext) { var formContext=executionContext.getFormContext(); var userSettings = Xrm.Utility.getGlobalContext().userSettings; var currentUserId=userSettings.userId; var fetchXML="?fetchXml=" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; Xrm.WebApi.retrieveMultipleRecords("team", fetchXml).then( function success(result) { var lookupValue = new Array(); lookupValue[0] = new Object(); lookupValue[0].id = result.entities[0].teamid; lookupValue[0].name = result.entities[0].name; lookupValue[0].entityType = "team"; formContext.getAttribute("ownerid").setValue(lookupValue); }, function (error) { console.log(error.message); // handle error conditions } ); }
André Arnaud de Cal...
294,217
Super User 2025 Season 1
Martin Dráb
232,978
Most Valuable Professional
nmaenpaa
101,158
Moderator