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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Sales forum / Setting Default values...
Sales forum

Setting Default values on entity records

(0) ShareShare
ReportReport
Posted on by 17

Hi All,

I've been searching for the right answer for this, but haven't really been able to find anything.  I've got a few scenarios where I need to set default values on entity forms, but haven't been able to find something for my use case:

I have a lookup field in the account entity for Payment terms.  It's a lookup to the "Payment Term" entity from field service.  The payment term entity has a name, and a days field (Where you specify the amount of days a customer has to pay an invoice.

Then, in the Business Unit entity, I created a new lookup field which I called "new_DefaultPaymentTerm" with one of the payment terms from the paymentterm entity selected.  The idea is to enter that default payment term specified in the business unit, into the payment term lookup field when i create a new account.

So scenario 1 is:  On new account creation, get the default payment term from the business unit of the current user, and select that as the value for Payment Term for the new Account.

Scenario 2 :  User creates a new invoice.  On Account selection, the payment term is looked up from the account entity, and selected in the PaymentTerm field, also a lookup field on the payment term entity.  Then the Days field value (which will be something like 30) is retrieved from the paymentterm entity record selected in the invoice, and the Due date is updated with Today + <paymentterm days> value.

I've seen a lot of reference to Javascript, actions, workflows, business process flows, but I'm not really getting a good answer.  Is this possible at all? Has anyone done this before?  Can anyone point me in the right direction?

Thanks!

I have the same question (0)
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    As you need to set the default value, this needs to be done as soon as the page loads. This can be done by JavaScript, Business Rule. Workflows you can't use as they work after the record creation/update i.e. not on load. The plugin on Pre-Operation - Retrieve can be used for your 1st scenario but can't be used for 2nd as there you need the default value as you select the account. So in short, you can rule out Plugin & workflow.

    Now with Business Rule, you can set default value but only static values i.e. you cannot retrieve the records from different entity (payment term from the business unit of the current user)

    The only option left is to use JavaScript with Web API's. It wouldn't be straight forward though-

    1) Write script on load, Get the BU of the user first. Then get the PaymentTerm from the BU and then sets this as default. Check the below article for reference-

    community.dynamics.com/.../get-lookup-value-from-other-entity-and-set-it-on-the-form-using-web-api-in-microsoft-dynamics-crm

    www.functionalthoughts.com/dynamics-365-web-api-retrieve-data-javascript

    community.dynamics.com/.../ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records

    2) Write script on change which will trigger on change of account and then again using web api, retrieve the payment terms from the account entity. You then need to retrieve the details of the payment entity and then do you days calculation.

    Hope this helps.

  • Tjopstas Profile Picture
    17 on at

    Thanks so much for your detailed Explanation Ravi.  how about non gui related?  For example, creating an account by converting a lead to a customer... Not sure if you can do nested lookups?  I keep the 'global" values in the business unit.. so something like, creating the account from a workflow, lookup the payment term "default" from the paymentterm lookup I save in the business unit.  something like, owningbusinessunit (from lead) > businessunit > new_defaultpaymentterm .... is that doable?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Yes, seems doable if you are creating an account record within workflow as their you can set the value. But this will not work if you create a new account record manually. So if this fits your requirement, go ahead :)

    Hope this helps.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Sales

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans