web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Auto populated field depending on a view

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Jarrod Williams Profile Picture
    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.  

  • Suggested answer
    Charles Abi Khirs Profile Picture
    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

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator 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
    Community Member Profile Picture
    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);
            }
    


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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans