Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    JJ
    CPM - Validation failed on create of a Incident
    Topic posted December 7, 2017 by JJ Bronze Crown: 15,000+ Points, last edited December 7, 2017 
    232 Views, 23 Comments
    Title:
    CPM - Validation failed on create of a Incident
    Content:

    Please see image for the error and the code block for the code - any reason for this?

    Code Snippet:

    Comment

    • JJ

      If I use the following just to see if it works at all

      $incidentOne->Subject=''; // i.e. setting the subject rather than the CTU.CTC

      instead of

      $incidentOne->CustomFields->CTU->CTC = RNCPHP\CTU\CTC::fetch(1264)

      It works and tests show fine i.e. no errors. Using the second one - I just get errors.

    • JJ

      When used in a widget (model called by a controller) this code works - but not in the CPM

              $incidentOne = new RNCPHP\Incident;
              $one = RNCPHP\CTU\CTC::fetch(1264);
              $incidentOne->CustomFields->CTU->CTC = $one;
              $cont = RNCPHP\Contact::fetch(38467);
              $incidentOne->PrimaryContact = $cont;
              $incidentOne->save();

       

    • Gursimran Singh Saini

      How about you move all this code in a Custom Script and call your Custom Script from CPM using cURL?

      I always do this with complex CPMs. Difficult to test and maintain otherwise.

    • JJ

      Suddenly has started working!

    • Venkateswar Bollapalli
      Gursimran Singh Saini said:

      How about you move all this code in a Custom Script and call your Custom Script from CPM using cURL?

      I always do this with complex CPMs. Difficult to test and maintain otherwise.

      View original

      Good approach. We usually put the custom process logic in a custom script and include the custom script in CPM. We can do cURL too, but cURL may not work with asynchronous CPMs.

      Regards, Venkat B

    • Suresh Thirukoti

      Wow JJ!! at last....blush.........As mentioned in CXDeveloper, maintain CPM Template in CP and use it to create multiple copies...we moved lot of CPMs this way....much easier to manage

      http://cxdeveloper.com/article/cpms-custom-process-management

      ~Suresh

    • Justin Lewandowski

      @JJ Did you ever find a solution?

    • JJ

      Yes