BadStudent
BadStudent

Reputation: 1

Creating a custom flow for D365 using power apps

I've created a application for D365 in my power apps enviornment. This application is called Projects its based of a table of the same name that has a many-to-many relationship with accounts and contacts. I've also created a custom button and I want to link a process/workflow to that button that will create a quick campaign for both the accounts and contacts related to that project entity.

I'vew tried to work it out in power apps but the farthest I have gotten is having a process that does a campaign and launches a campaign activity but I do not see a way in power apps to connect that activity to a account/contact related to the project. I've also tried to use power automate but I do not think any of the dataverse options will work.

Upvotes: 0

Views: 34

Answers (1)

Laviza Falak Naz
Laviza Falak Naz

Reputation: 446

You can achieve this in few steps.

  1. Set up a button on Ribbon to initiate the process. You can use RibbonWorkbench tool by XRMToolBox to do this.

  2. Link this button to a command with a JavaScript Library function and pass the primary Control.

enter image description here

  1. Add your JavaScript function to Send request to an HTTP Triggered power automate flow. Add the URL to this function

function callHttpFunction(recordId) {
var formContext = primaryControl; // Using primaryControl directly as the form context
var recordId = formContext.data.entity.getId();
  var url = "Replace this URL with the actual endpoint of your HTTP function";
  var data = JSON.stringify({
    recordId: recordId
  });

  var req = new XMLHttpRequest();
  req.open("POST", url, true);
  req.setRequestHeader("Content-Type", "application/json");
  req.onreadystatechange = function() {
    alert("Sync started successfully.");
  };
  req.send(data);
}

  1. Once done, Head on to your PowerAutomate flow. I have used a record from 'Orders' entity to create an email campaign for related accounts using PA. You must create an email message first using a "Add a Row" connector.

enter image description here

Upvotes: 0

Related Questions