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
Scott BScott B 

Problem with auto assignment rule header

I can't seem to get the auto assign rules to fire.  I create a lead, and it keeps getting assigned to the API account that I am using

            _AssignmentRuleHeader arh = new _AssignmentRuleHeader();
            arh.setUseDefaultRule( new Boolean( true ) );
            m_Binding.setHeader("SforceService", "AssignmentRuleHeader", arh);
            createResult = create( createObjs );
            //clear the soap headers to make sure that the next call does not use the auto assign header unintentionally
            m_Binding.clearHeaders();
            //reset the headers
            _SessionHeader sh = new _SessionHeader();
            sh.setSessionId( getSessionId() );
            m_Binding.setHeader( "SforceService", "SessionHeader", sh );
            m_Binding.setHeader( "SforceService", "useCaseSafeIDs", "0" );

 

Scott BScott B
As an aside, using api version 4.0
DevAngelDevAngel

Hi ScottB,

Due to an error in the sample code in the documentation, this will not work the way your are setting it.

Rather than add the header like this:

binding.setHeader("SforceService", "AssignmentRuleHeader", arh);

You should add it like this:

binding.setHeader(new SforceServiceLocator().getService().getNamespaceURI(), "AssignmentRuleHeader", arh);

 

The doc is due to be updated shortly.

Scott BScott B
THere is no GetService on SforceServiceLocator.  Perhaps another method??
Scott BScott B
I tried getServiceName().  That did not appear to do it either.
Scott BScott B

OK.

Here is what worked for me (finally)

            _AssignmentRuleHeader arh = new _AssignmentRuleHeader();
            arh.setUseDefaultRule( new Boolean( true ) );
            m_Binding.setHeader("SforceService", "AssignmentRuleHeader", arh);
            m_Binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "AssignmentRuleHeader", arh);

Thanks to DevAngel for getting me headed in the right direction.  And curses upon those who wrote the bad documentation!    Just kidding.

DevAngelDevAngel

Hi Scott,

Yup, getServiceName().getNamespaceURI().  I was writing this from memory, sorry.