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 365 | Integration, Dataverse...
Unanswered

Desactive WPF in CRM 365

(0) ShareShare
ReportReport
Posted on by 694

Dears, good morning,

I have the following case in my organization.

Upon completion of a custom activity, I gain the Opportunity by changing the Status to Earn, but the Enterprise Workflow remains active.

Can I lose the business process flow in any way via javascript or the same flow?

Tanks

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Ricardo,

    1. How do you check whether a custom activity has been completed?

    2. Do you mean upon completion of a custom activity, the regarding Opportunity would be closed as Won(earn in you description)?

    3. Is step 2 implemented using a workflow? (It would be helpful if you could let me know what the "but the Enterprise Workflow remains active" means.)

    4. What does "lose the business process flow" mean? Would you like to hide it when the opportuntiy status had been set to Earn?

    5. Would your title "Desactive WPF" actually means "Desactive business process flow"?

    Regards,

    Clofly

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello good day,

    Thanks for the reply, come on.

    1- I wait until the Status is completed.

    2- That's right, after completing the activity I change the Opportunity Status as Win or Lost.

    3 - Losing the business process flow means putting it as aborted or terminated depending on the Status.

    4 - Yes, inactive means the business process flow of that opportunity.

    Tanks

  • cloflyMao Profile Picture
    25,210 on at

    Hi Ricardo,

    I thought you could hide BPF by javascript directly.

    function hideBPF(executionContext) {
      var formContext = executionContext.getFormContext();
      var formType = formContext.ui.getFormType();
      // Check whether current opportunity has been closed.
      if (formType == 3 || formType == 4) {
        formContext.ui.process.setVisible(false);
      }
      // Hide BPF by Opportunity status
      // var status = formContext.getAttribute("statecode").getValue();
      // if (status == 1 || status == 2) {
      //   formContext.ui.process.setVisible(false);
      // }
    }

    After an opportunity has been closed as Won or Lost, the form will be read-only,

    then we can hide BPF by the form type.

    Another option would be that we check current opportunity status,  

    1 equals Won, 2 equals Lost.

    Regards,

    Clofly

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Clofly Mao good morning,

    Thanks for the feedback, I had researched this code.

    Yes, I could hide it, but the user needs to see the answers to each question, as this needs to disable / disable Business Process Flow, understand?

    I need to see a way to do this without having to develop a plug-in, because via workflow I can't perform this action.

    hug

  • cloflyMao Profile Picture
    25,210 on at

    Hi Ricardo,

    If you're working in UCI, then you could take below code as reference:

    function onLoad(excontext) {
    
      var formContext = excontext.getFormContext();
      var formType = formContext.ui.getFormType();
      // Check whether current opportunity has been closed.
      if (formType == 3 || formType == 4) {
        formContext.data.process.addOnPreStageChange(myFunction);
      }
    
    }
    
    function myFunction(excontext) {
    
      var alertStrings = { confirmButtonLabel: "Ok", text: "The opportunity has been closed.", title: "Notice." };
      var alertOptions = { height: 150, width: 250 };
      Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
        function success(result) {
          console.log("Alert dialog closed");
        },
        function(error) {
          console.log(error.message);
        }
      );
      excontext.getEventArgs().preventDefault();
      return false;
    
    }

    If the current opportunity form is read-only, bind OnPreStageChange event to BPF, 

    then prevent user to move to next/previous stage by excontext.getEventArgs().preventDefault();

    while user can still see other stages fields.

    pastedimage1577769786070v1.png 

    Regards,

    Clofly

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 45 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 36

#3
Satyam Prakash Profile Picture

Satyam Prakash 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans