function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dmaysdmays 

Invoke Lead Assignment Rules

Is it possible to invoke a lead assignment rule when uploading new leads through the API?  I found a posting from May 2004 which suggested the answer is "no", but I'm inquiring, hoping this has been implemented.  If it is possible, could you provide a code example (.Net preferred)?

Thanks!

ScotScot
Yes, you can. Check out the API document, at the end of page 142 (Leads/Usage). Using an AssignmentRuleHeader, you can specify the rule to be used, or that the default rule should be used.  There's an example there for java which might get you started.
dmaysdmays

Thank you Scot for the info. 

In case anyone's interested, here's my .Net code for invoking a Lead Assignment Rule called "Territory Assignments":

sforce.SforceService binding = ... get your login object ...

sforce.AssignmentRuleHeader arh = new sforce.AssignmentRuleHeader();

sforce.QueryResult qr = null;

binding.QueryOptionsValue = new sforce.QueryOptions();

binding.QueryOptionsValue.batchSizeSpecified = false;

try

{

       qr = binding.query("select ID from AssignmentRule where Name = 'Territory Assignments' and

              Ruletype = 'leadAssignment'");                        

       if (qr.size == 0)

              arh.useDefaultRule = true;

       else

              arh.assignmentRuleId = (qr.records[0].Id);

}

catch (Exception ex)

{

       Debug.WriteLine(ex.Message);

}

binding.AssignmentRuleHeaderValue = arh;

 

JesseJesse

Thanks dmays... that's just the bit of code I was looking for.

Learning sForce API + .NET + Visual Studio = confused dev