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...
Answered

Business Unit Specific New Contact Form

(0) ShareShare
ReportReport
Posted on by 333

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)  

pastedimage1674209422654v2.png

New Business Unit created -  Veterans Services 

pastedimage1674209346944v1.png


Created a New Form

pastedimage1674209722086v3.png

Assigned the New from to the Security Role

pastedimage1674209799063v4.png

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

pastedimage1674209997213v5.png

pastedimage1674210045099v6.png


I have the same question (0)
  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi,

    Can you please check your model driven app?

    In app designer mode, select the required entities then check all forms are included in app as shown below screenshot:

    pastedimage1674210646606v1.png

    I did tried the all the above steps:

    1. Created New Form
    2. Created New Role
    3. Enabled the form for New Security Role
    4. Added the New Security Role to My user and Also, tried by adding new security role to Team.

    It is working for me.

  • Chris1968 Profile Picture
    333 on at

    Hi,

    Thank you for this.  

    It wasn't so added it and it works.  Just any additional question and hope you don't mind.  

    How can I make it default that when a new contact form is created the owner defaults to the Team name the user is a member of?  Is this possible or do you have to use the assign function??

  • Verified answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi,

    I would suggest to try Javascript function, which will trigger on load of contact form and in load it will get the Team details for that user.

    And once retrieve you can set owner field using FormContext.

    Same logic you can try in plugin or power automate. Here it will trigger on create of Contact record.

    Hope this helps.

  • Chris1968 Profile Picture
    333 on at

    Hi,

    Sorry not really used java script before can you provide some details, examples.

    Used Power Automate but not with D365

  • Pradeep Rai Profile Picture
    5,489 Moderator on at

    Okay, give me sometime.

  • Chris1968 Profile Picture
    333 on at

    Hi,

    Thank you

  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

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


  • Chris1968 Profile Picture
    333 on at

    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'/>"+

  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    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

  • Chris1968 Profile Picture
    333 on at

    Hi,

    Sorry should have mentioned, I've done those steps

    pastedimage1674814377783v1.png

    pastedimage1674814427466v2.png

    pastedimage1674814450343v3.png

    But my name still appears as the Owner??

    pastedimage1674814530835v4.png

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 45 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 36

#3
Satyam Prakash Profile Picture

Satyam Prakash 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans