Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

How to save all records to recalculate values

Posted on by 95

I have a problem. I have modified to calculate some fields in an form, they are only calculate when I open and save a record.

 Form include Fields with:

Calculated type.

Simple type: calculated by JavaScript when user load and save form.

How can I recalculate for all old records without open and save form? values will recalculate/display in views correctly.

Is there any batch job to do that?

Thanks.

  • Shweta_Shukla Profile Picture
    Shweta_Shukla 105 on at
    RE: How to save all records to recalculate values

    In that case I think JavaScript won't be a correct option to go with.. Can you not perform the same calculation using Workflow and fire it on-demand for selected records?

  • Shweta_Shukla Profile Picture
    Shweta_Shukla 105 on at
    RE: How to save all records to recalculate values

    In that case I think JavaScript won't be a correct option to go with.. Can you nit perform the same calculation using Workflow and fire it on-demand for selected records?

  • baochau Profile Picture
    baochau 95 on at
    RE: How to save all records to recalculate values

    I tried your idea, onChange fired when I open form and change temp field, but when I tried to use bulk update 2 records on view, the event is not fired. The script could be not triggered. Do you have any idea?

  • baochau Profile Picture
    baochau 95 on at
    RE: How to save all records to recalculate values

    Thanks you, I will try bulk update as you suggestion

  • baochau Profile Picture
    baochau 95 on at
    RE: How to save all records to recalculate values

    When I open any record and save, this field is calculated. (Execute JavaScript)

    When I check old records in view (list), this field is empty.

    How can I update to calculate old records without open and save form?

  • Shweta_Shukla Profile Picture
    Shweta_Shukla 105 on at
    RE: How to save all records to recalculate values

    As it is a simple field, you can make use of your JavaScript function to trigger it on change of your temporary field,

    • If not, you can create a temporary field,
    • add it on form. Register your JavaScript function onChange of this field. Publish.
    • on entity's view, select all older records, perform bulk edit records (click on edit button on ribbon menu after you select records) and modify that temporary field
    • Check if the calculated fields have been modified?
    • If so, remove the temporary field from form.

    Mark answer as verified if it resolved your problem.

  • baochau Profile Picture
    baochau 95 on at
    RE: How to save all records to recalculate values

    Data type: currency

    Field type: Simple

    The field is calculated in JavaScript (form load and save event)

    20200525212659.jpg

  • Shweta_Shukla Profile Picture
    Shweta_Shukla 105 on at
    RE: How to save all records to recalculate values

    Firstly, can you confirm what is the datatype of that fields that you want to modify? If you can send the screenshot of that field that'll be ideal.

  • baochau Profile Picture
    baochau 95 on at
    RE: How to save all records to recalculate values

    How is the simple field calculated by javascript when form load and save ? it's calculated auto?

  • Suggested answer
    David Yu Profile Picture
    David Yu on at
    RE: How to save all records to recalculate values

    Hi,

    Calculated fields are computed on database level, and they are automaticaly updated on views and forms. We don't need to recalculate that information.

    But if you want to recalculate your rollup fields, you may need use CalculateRollupFieldRequest.

    docs.microsoft.com/.../microsoft.crm.sdk.messages.calculaterollupfieldrequest

    Here is a good blog about the difference.

    community.dynamics.com/.../dynamics-crm-calculation-amp-rollup-fields

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans