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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Business Process Flows and Required Fields Question

(0) ShareShare
ReportReport
Posted on by 80

Good Day:

  I am fairly new on CRM 2015 Business Process Flows(BPF) and have a question on Field Requirements.  I would like to prevent the movement to the "Next Stage" of a BPF, unless there is data in at least one of following fields(Business Phone OR Mobile Phone OR Email).  I do not need to guarantee that ALL fields are completed, only than 1 field is completed.  Is there a way to do that?

Thanks,

Omar

*This post is locked for comments

I have the same question (0)
  • TomSmelser Profile Picture
    1,570 on at
    RE: Business Process Flows and Required Fields Question

    Omar,  

    You should be able to accomplish this by creating a calculated field on the entity.  That is accomplished by adding a new entity field and assigning it type of "calculated". For the calculated option formula you can set it to check for value1 or value2 or value3 then "something".  In all other cases it would be blank.  Then in your BPF just check this 1 entity field is Required.  

    Hope that is helpful.  Best regards.

    Tom.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Business Process Flows and Required Fields Question

    Hi,

    In BPF against each field, you have a checkbox called required, you simply check it. Then system wont allow you to go to next stage unless some data is there in your required field.

    Hope it helps.

  • Verified answer
    ThomasN Profile Picture
    3,190 on at
    RE: Business Process Flows and Required Fields Question

    Hi Omar, thank you for reaching out.

    You can perform this through Javascript. I have adjusted the code from Inogic Blog and from another Inogic Post Here to meet both requirements, changing the required level and doing so only on stage change.

    You will want to set all three fields as required in the Business Process Flow editor. Also the fields I used are just for reference. You will want to up those fields in quotations with the schema name of the fields on your record with the process flow. Then create a web resource as a JavaScript type and copy this code with your schema names. Place the script on the form and assign the function to the OnLoad Event. We cannot tie to events in the Business process flow without adding the field to the form.

    Let us know if this works for you. Have a great day!

    -Tom

    function OpportunityOnLoad() {
    	var functionName = "OpportunityOnLoad";
    	
    	try {
    		var type = Xrm.Page.ui.getFormType();
    		
    		// Check if the form is create or update
    		if (type ==1 || type == 2) {
    			
    			// Set Required fields
    			requirePhoneFields();
    			
    			// Register stage onchange event
    			Xrm.Page.data.process.addOnStageChange(requirePhoneFields);
    		}
    	} catch (e) {
    		throwError(functionName + (e.description || e.message));
    	}
    }
    
    function requirePhoneFields() {
    	var functionName = "requirePhoneFields";
    	
    	try {
    		
    		// Get the value for the fields to determine if any have data
    		// For BPF fields they must have header_process_<attributeName>
    		var businessPhone = Xrm.Page.getControl("header_process_telephone1").getAttribute().getValue();
    		var mobilePhone = Xrm.Page.getControl("header_process_mobilephone").getAttribute().getValue();
    		var emailField = Xrm.Page.getControl("header_process_emailaddress1").getAttribute().getValue();
    		
    		// Check if Fields are required
    		if (businessPhone != null || mobilePhone != null || emailField != null) {
    			
    			// Clear the requirement level on all fields
    			businessPhone.setRequiredLevel("none");
    			mobilePhone.setRequiredLevel("none");
    			emailField.setRequiredLevel("none");
    		}
    	} catch (e) {
    		throwError(functionName + (e.description || e.message));
    	}
    }


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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans