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
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
Here is how to add a workflow button to a Power Apps portals page:
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)
};
}
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
i forgot to say, that i want to create a button to activate a workflow on web template
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156