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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Use Workflow to Create New Record from Business Process Flow

(0) ShareShare
ReportReport
Posted on by 120

Hi,

I've created a basic Business Process Flow (BPF) - the first stage based on the Account Entity. I've also set up an On Demand Workflow based on the Account Entity and set this to create a new Contact Record. I added this workflow to the first stage of my BPF and set it to trigger On Exit.

I've created a second stage in  my BPF based on the Contact Entity. I want the Contact record to be automatically created when I select the second stage in my BPF. I had assumed that by clicking the second stage, the workflow would create a new Contact record automatically, however it doesn't happen.

I can only create a new Contact at the second stage if I select Next Stage and the + sign to Create.

My workflow will create a new Contact if I select Run Workflow from the command menu.

I'm not sure why the workflow is not running automatically from my BPF. Can anyone advise please?

We're on Dynamics 365 online V8.2.

Many thanks,

Agnes

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    Hi Agnes,

    you can use javascript if you want, on the stage change you can check your condition and create a record,

    below is the code, keep it on page load,

    Keep the OnLoad function on page load

    function OnLoad() {

     // *** Whenever the stage changes trigger an onchange function

     Xrm.Page.data.process.addOnStageChange(stageOnChange);

    }

    function stageOnChange() {

    var stage = Xrm.Page.data.process.getActiveStage();

     //get the stage and check your stage Id/name

     //Create contact

     var contact= {};

    contact.LastName= "Test JS Contact";

    SDK.REST.createRecord(

    contact,

    "contact",

    function (contact)

    {

    alert("contact Created with name" + " " + contact.lastname);

    },

    errorHandler

    );

    function errorHandler(error) {

    writeMessage(error.message);

    }

    }

    Best Regards,

    Shahbaaz

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    Stage Exit, only triggered when you move to next stage.

    alexmscrm.blogspot.my/.../dynamics-365-workflow-within-business.html

    if you want to create a contact where the moment you select the stage,you need to use JS

    addOnStageSelected function, but make sure you handle scenario where how many times you want to create the contact, every time or one time only.

    nishantrana.me/.../new-addonstageselected-and-addonstagechange-method-for-process-in-crm-2015

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans