BPF Process Stage Name not populating on records in D365 v9 [Deprecated] and workaround.

At times, users are unaware of the deprecation announced for D365 v9 version earlier in 2018 or simply, they’re not aware whether to look for deprecation announcements. One of the most common instances I’ve come across lately are when people complaining about the Process Stage Name entity not updating post the v9 update.

missingData

Deprecated Feature – Process

So when you try to add these columns in you entities’ views, you’ll see that StageID (Process Stage) is now shown as Deprecated.

deprecatedField

Read More About It Here

Here’s the Microsoft link where this is stated and other deprecations for upcoming D365 versions:

https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming#legacy-process-related-attributes-in-entities-are-deprecated

Alternative/Workaround

But, it is important that you also have a workaround at hand to keep the data up to date. Here’s a quick workaround to get the Stage Name.

  1. Create a custom Single Line of Text field on the entity that you need the Stage name on. In this case, Opportunity entity.
  2. Create a Real-time Workflow on the BPF entity itself. In this case, it was the Opportunity Sales Process BPF’s entity called as ‘Opportunity Sales Process’.
    wfCreate
  3. The workflow will be triggered when the Process is Applied and then Active Stage field is updated on the BPF.
    wfBody
  4. And in the Step, it will only update the Opportunity’s custom field to the Active Stage.
    wfUpdateStep
  5. That way, you can have the Stage Name data in your custom field and use that instead.
    populatedDate

 

Hope this helps! 🙂

 

 

Advertisements

Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

While working with BPF fields using JavaScript, there can be instances where you might want to keep the field locked in a certain stage but unlocked in another stage. And using Xrm.Page.getControl(controlName) or for v9 – getFormContext.getControl(controlName) should differentiate between the 2 fields?

Let’s see what we need to do here.

Scenario

  1. Let’s say I want the users to enter Customer Need data in Develop Stage.
    unlockedField
  2. But, just view what data is present in Propose Stage shown below, not modify it. (I’ve just renamed the field to Summarize Customer Need instead)
    lockedFields

JavaScript Usage to access the Control

  1. Now, since the Summarize Customer Need field is the second time, using getFormContext.getControl(“header_process_customerneed”) will be fetched to disable the first field only i.e. Customer Need in Develop stage.
    unlockedField
  2. To access Summarize Customer Need, you need to append “_1” to the control name for the second occurrence. And _2 and so on for further occurrences.
    Here’s the sample code which I used to access Summarize Customer Need to access the second occurrence of the field and use setDisabled(true) to lock it –
    code3. And that way, you’ll be able to access Summarize Customer Need control and do your desired operation (like even make it hidden or visible depending on your scenario) –
    lockedFields
    Hope this helps!

What happens when you force fields on BPF to be required programatically or using Business Rule

I had a requirement where I needed to make certain fields on BPF as required.

So, I tried accessing the control using Xrm.Page.getControl(“header_process_description”) and then getAttribute().setRequiredLevel(“required”) on it would serve my purpose. But actually, not!

To set perspective, the code runs and make the field required too. But there’s a catch!

Required fields on the BPF are supposed to throw an error when you are trying to move to the next stage without filling in the required fields.

But, using the code I’m talking about above (sample shown below), will force you to save the form entirely. Let alone moving the stages further.

jsCode

That when ‘How Did You Hear About Us?’ field has Employee Referral as value, make Purchase Process field required.

empoyeeReferalSet

Field is on the BPF

fieldOnBPF

But prompts me to save the form
promptToSave

 

Workaround

The easiest workaround to this is using the conditional branching of your business process flow –

You can use conditional branching of the BPF itself – You can replicate the same stage twice, one having your required field and other having that same field as optional.

bpfBranching

However, limitations I found with this approach is –

  1. I couldn’t use the same for the first stage of the BPF –
    limitation1
  2. The condition had to be from the previous stage itself
    limitation2

P.S. Business Rules isn’t a solution as well. Also, I tried to inverse the logic by first making the field required in the BPF itself and then trying to make it not required using code. That doesn’t work either.

Hope this gives an idea. Let me know if you have other suggestions! 😊