Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Insert a button that activate a workflow on portals

Posted on by 250

Hello everyone my name is Taniguchi, and i would like  to know if its possible to create a button to activate a workflow, and if its possible, how can i do it ?

*This post is locked for comments

  • Nick.Doelman Profile Picture
    Nick.Doelman 1,947 Most Valuable Professional on at
    RE: Insert a button that activate a workflow on portals

    Here is how to add a workflow button to a Power Apps portals page:

    https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/entity-forms#entity-form-action-configuration

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Insert a button that activate a workflow on portals

    Create a new button on web page and execute below code on click of that button:

    QueryExpression objQueryExpression = new QueryExpression("workflow");

    objQueryExpression.ColumnSet = new ColumnSet(true);

    objQueryExpression.Criteria.AddCondition(new ConditionExpression("name", ConditionOperator.Equal, "Name of workflow"));

    objQueryExpression.Criteria.AddCondition(new ConditionExpression("parentworkflowid", ConditionOperator.Null));

    EntityCollection Workflows = service.RetrieveMultiple(objQueryExpression);

    foreach(Workflow in Workflows.Entities)

    {

       var activateRequest = new SetStateRequest

                       {

                           EntityMoniker = new EntityReference

                               (Workflow.EntityLogicalName, Workflow.Id),

                           State = new OptionSetValue((int)WorkflowState.Activated),

                           Status = new OptionSetValue((int)workflow_statuscode.Activated)

                       };

    }

  • Suggested answer
    RE: Insert a button that activate a workflow on portals

    Hi Taniguchi

    Assuming you are using Microsoft Portal (online) there is no OOTB way to add a button triggering a workflow. There are however ways to achieve this with some custom code

    These are 2 option I think of

    1. Use an Entity Form as a proxy to start the workflow. The only way Microsoft really provides for sending data to dynamics in the portal is by submitting an entity form

    If you need to trigger a process in dynamics you can populate data in a hidden field on an entity form, submit that form to dynamics (which will create or update a record in dynamics), then run a plugin or workflow on that create/update message in dynamics

    So for your scenario you could add an entity form to the web template / web page in the portal, hide the form through CSS or JavaScript, then when your button is clicked run some JavaScript to populate the hidden form with some appropriate data and invoke the submit button

    2. You could create an external web service or function hosted in say azure which triggers the workflow. This could be called directly by JavaScript when the button is clicked

    Probably not as good an option as it requires a separate deployment component. Generally I think it is better to keep these kinds of solutions entirely within the dynamics and portal infrastructure if possible

    Hope this helps

  • TaniSantos Profile Picture
    TaniSantos 250 on at
    RE: Insert a button that activate a workflow on portals

    i forgot to say, that i want to create a button to activate a workflow on web template

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans