Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Is there a way to save the current record as a workflow step?

(0) ShareShare
ReportReport
Posted on by 1,589

I have a Dynamics 365 Form with a related Business Process with 3 steps.

The steps cannot change for business reasons nor can the chevron fields change either.

When the user arrives at business process step # 2, he has to enter a dollar amount in the business process chevron at the top of the screen.

90% of our users will do this and not hit the save button before clicking the next stage button on the business process chevron.

We do not want to force them to click save. That is not their behaviour. They will set the dollar value and click the chevron to advance to stage 3.

A workflow runs when they enter stage three, but because the record didn't save, the dolllar amount they entered in the chevron did not save to the field on the form before the workflow runs.

This causes the values that need to exist prior to the workflow being able to manipulate them, to not be present.

The easiest fix is if we can make the very first step of the workflow be to save the record before starting.

How can we set as a workflow step to save the record keeping in mind that the workflow executes on the Job Business Process entity and it needs to save the actual job record.

  • Verified answer
    ACECORP Profile Picture
    1,589 on at
    RE: Is there a way to save the current record as a workflow step?

    We ran this down in more detail and determined that using a script presented other issues. We ultimately had to create a step in the business process chevron that sits between the two stages. That was the only way to solve the problem without creating more problems. We also determined the answer to our original question is NO, there is no way to create a workflow step that saves a record because by definition, workflows run and then save at the end. I will credit your answer as being valid, so you get the credit for the time. Your proposed solution works but we could not use it due to extenuating factors.

  • ACECORP Profile Picture
    1,589 on at
    RE: Is there a way to save the current record as a workflow step?

    Apparently I was incorrect when I assumed the name of the field on the form that the data from bpf field header_process_cpp_totaljobamount_2 gets copied into was cpp_totaljobamount_2, the bfp field is correct but when the form is saved, the actual field that holds that data is cpp_dollarsbooked.

    So I supposed I need to first figure out if cpp_dollarsbooked is the same field or if there is something else going on.

  • ACECORP Profile Picture
    1,589 on at
    RE: Is there a way to save the current record as a workflow step?

    When you say "trigger", I tried added the following JavaScript to the onchange event of the cpp_totaljobamount_2 field but it doesn't run because the change is made to the version of the field that appears in the Job Business Process and not to the field on the Job form.

    function AutoSaveFormOnFieldChange() {
        var formContext = executionContext.getFormContext();
            formContext.data.entity.save();
        return;
    }


    So I am not quite sure what you mean when you say 'trigger'.

  • Suggested answer
    Ben Thompson Profile Picture
    6,350 on at
    RE: Is there a way to save the current record as a workflow step?

    A trigger on the cpp_totaljobamount_2 will also run when the field within the bpf header is changed...

    Edit to add - (and I probably need to make this a blog post) - workflows, plugins.... are all back end processes and have no access to the updated information contained within your browser window (or outlook / ipad / iphone screen).

    Hence if you want the updated value available to the backend systems when the next stage button is pressed, a browser based option such as Javascript (or auto-save functionality) is the only way you can be sure that the data is saved to the database before the next stage button is pressed.

  • ACECORP Profile Picture
    1,589 on at
    RE: Is there a way to save the current record as a workflow step?

    We would prefer to do this via workflow if possible.

    However, if workflows don't support this and we must use built in JavaScript, how and where can I attach the code to the field named "header_process_cpp_totaljobamount_2"?

    I don't see that field name in my job entity.

    The field name cpp_totaljobamount_2 is in my job entity, but that is the field as it is named on the actual form itself and not at the top on the business proces chevron.

    The root of the problem is the value is entered into header_process_cpp_totaljobamount_2 in the chevron but it is not saved or accessible on the cpp_totaljobamount_2 field of the form until the record is saved. The workflow is looking for it, but its not there until the form is saved.

    That's my problem. I need to somehow save the form when a value is entered in "header_process_cpp_totaljobamount_2" but I can't find that field on any form to attach the javascript to onchange.

  • Verified answer
    Ben Thompson Profile Picture
    6,350 on at
    RE: Is there a way to save the current record as a workflow step?

    Could you add a save request via javascript triggered when the field is updated?

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 > Dynamics 365 general forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans