Integrations and APIs for Service

Get Involved. Join the Conversation.


    Bryan Scarborough
    Custom Process Error/ConfusionAnswered
    Topic posted September 11, 2019 by Bryan ScarboroughBlue Ribbon: 750+ Points, last edited September 11, 2019, tagged Connect PHP 
    35 Views, 4 Comments
    Custom Process Error/Confusion


    I am trying to setup my first Custom Process to create an entry in a Custom Object when an incident is saved.  I am currently running into an issue with the Setup Function in the TestHarness.  The code is below.  

    I am getting the following error on the $newPage->SentBy = $testObject->AssignedTo->Account->Name; line

    Type mismatch: Must be string

    The Custom Object field is a string and as far as can see the Name field should also be one, so why is this giving me an error?  There is an account Assigned to this Incident.


    Thank you

    Code Snippet:

    Best Comment

    Tushar Gupta

    Can be done through the report by using the transactions table.



    • Lakshay Bhalla

      Hi Bryan,


      You code is almost correct, The thing is the line: "$testObject->AssignedTo->Account->Name;" is returning an object.

      To get the name of the assigned account just add the First or Last to your code line.

      You can add the combination of both as well.

       $newPage->SentBy = $testObject->AssignedTo->Account->Name->First." ".$testObject->AssignedTo->Account->Name->Last;

      One more thing to add is that always first test your code in the custom script, then make the CPM. wink



    • Bryan Scarborough

      Thank you.  I was able to get that working.  So now I can get the person that an incident is assigned to, but is there a way to find who actually made the edit on the incident, as that not is not guaranteed to be the person that is assigned to the incident?

      • Tushar Gupta

        Can be done through the report by using the transactions table.

        • Robert Surujbhan

          There's a better way.  Bryan, in your Custom Process code, you can run a ROQL query using a special function named curAdminUser().  This will return the ID of the account/agent that made the edit (which triggered the request to the server which caused your CPM to run). Using this ID, you can then fetch the Account object.  You could also run curAdminUserName() which would return the account's Full Name as a string (First + Last).  You'll want to add some logic to make sure the result from the query is valid since Incidents can be edited other ways as well, but this should work for you if you need to know who made the edit vs. who is assigned. 

          Let us know if you need some sample code for your PHP!