Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Auto populated field depending on a view

Posted on by Microsoft Employee

I have two views 'Manufactures' and 'Clients' in the Account entity. Is it possible to fill the field 'customertypecode' by Manufacturer value if a new record is created from 'Manufactures' view? The same behaviour is expected for 'Clients' view.

Manufacturer and Client are values of option set which is assigned to 'customertypecode' field.

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto populated field depending on a view

    It's possible to implement this function. It's required to override 'New' button in Ribbon Workbench.

    Function which should be called in overridden button:

    function NewAccountForm(PrimaryControl) {
                var viewSelector = PrimaryControl.getViewSelector();
                var viewName = viewSelector.getCurrentView().name.toLocaleLowerCase();
                var customertypecode;
                var entityFormOptions = {};
                entityFormOptions["entityName"] = "account";
                var formParameters = {};
                var accountTypes = [
                    { name: 'client', value: 923720001 },
                    { name: 'manufacturer', value: 923720002 },
                ];
                accountTypes.forEach(function (element1) {
                    if (viewName.indexOf(element1.name) >= 0) {
                        var viewWithMultipleAccountTypes = false;
                        accountTypes.forEach(function (element2) {
                            if ((element1.name != element2.name) && (viewName.indexOf(element2.name) >= 0))
                                viewWithMultipleAccountTypes = true;
                        });
                        if (!viewWithMultipleAccountTypes)
                            customertypecode = element1.value;
                    }
                });
                if (customertypecode) {
                    formParameters["customertypecode"] = customertypecode;
                }
                Xrm.Navigation.openForm(entityFormOptions, formParameters);
            }
    


  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Auto populated field depending on a view

    Hi,

    I am afraid there isn't any standard/ out of box way to achieve this requirement. This Is because when you create a new record, it won't have the context from which view the new is clicked. You can however set single value (either manufacturer or client" by default.

    Hope this helps.

  • Suggested answer
    Charles Abi Khirs Profile Picture
    Charles Abi Khirs 3,569 on at
    RE: Auto populated field depending on a view

    Hello,

    I would suggest is:

    1. Create 2 workflows against manufacturer and clients entities.

    2. These workflows will be triggered on create.

    3. Add condition to check if the account lookup of record created is not empty

    4. Add step to update the optionset field of the parent account to the desired value

  • Jarrod Williams Profile Picture
    Jarrod Williams 1,747 on at
    RE: Auto populated field depending on a view

    If it is a view within a form, so you are going from an account record and you create a new something else record you can use mappings to default value it, but there isn't a way to do it if you are just looking at one of two views for account and then just click new.  You don't have a source URL formatted the same way that you did in like crm 4.0 that you could say, oh, it was looking at this view.  

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans