Start a Sales Process for an Opportunity via the SData API in Infor CRM

If you’re using SData to create Opportunity records, you’ll likely need to also start sales processes for those opportunities as well. Sales processes in Infor CRM (SalesLogix) is a mess with all the XML etc. Luckily, there’s an out of the box business rule we can use that does all the messy stuff for us. Let’s take a look at how to do this via the Infor CRM SData API.

Note: We’ll be using the DotNetSDataClient library in this example.

In a nutshell, we’ll need a few things to accomplish this:

  1. First, you’ll need the plugin ID for the sales process you want to start. You can find the Sales Processes in the Plugin table. Sales processes have a TYPE=1, so you can use the following to find the one you want: select * from sysdba.plugin where type = 1
  2. Next, in your code, you’ll create a new/empty SalesProcesses entity via SData
  3. Last, you’ll call the InitSalesProcesess business rule on that new entity and provide the plugin ID for the sales process you want to start and the opportunity ID for the opp you’re starting it for

The complete code to do all of this looks like the following:

// create the SData client 
var client = new SDataClient("http://localhost:3333/sdata/slx/dynamic/-/")
{
    UserName = "admin",
    Password = ""
};

// first create a new/empty salesprocess record
var salesProcess = client.Post(new {}, "salesProcesses");

// now call the InitSalesProcess business rule to start the process and 
// attach it to the opportunity. We'll pass into the rule the new
// salesprocess entity we created along with the plugin ID of the 
// process and the opportunity ID we're attaching it to.

var processPluginId = "p6UJ9A000501"; // ID of the process in the plugin table
var opportunityId = "ODEMOA0000CR"; // ID of the oppportunity we're attaching it to 

// create the payload for the business rule
var initProcessRule = new
{
    Request = new
    {
        entity = salesProcess,
        pluginId = processPluginId,
        entityId = opportunityId
    }
};

// execute the business rule 
client.Post(initProcessRule, "salesProcesses/$service/InitSalesProcess");

That’s it. You can go to the opportunity and you’ll see the sales process started for it. BTW, this code is even simpler if you’re in the Infor CRM client itself (and not working via SData), for example from some form or other business rule/entity event. The steps are the same, but there’s a bit less to do:

var salesProcess = Sage.Platform.EntityFactory.Create<ISalesProcesses>();
salesProcess.InitSalesProcess(pluginID, opportunityId);

Lastly, I should mention, if you’re using a completely external application (and not using SData), I do also have an open source library that does all this using Sublogix as well. See that code and get the DLL here: CustomerFX/SalesProcessAdapter (works with all versions of Infor CRM/SalesLogix and great for LAN environments).

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!