Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Natraj Buddi
    Unable to Save New Contact in CPM through Custom ScriptAnswered
    Topic posted June 24, 2016 by Natraj BuddiBlue Ribbon: 750+ Points 
    299 Views, 19 Comments
    Title:
    Unable to Save New Contact in CPM through Custom Script
    Content:

    Hi All,

    I am trying to Create new contact from CPM by simple Custom Script, i am just hard coding all field values and saving the record.Not getting any error , but could not able to see my new contact in database.I mean when i search for my contact record not found.

    Can any one help me please..

     

    Thanks,

    Natraj

     

    Version:
    i am using Feb 2016 version
    Code Snippet:

    Best Comment

    Mark Rhoads

    Running a test in the Process Designer does not allow anything to be committed to the database, even if the script contains a commit.

    To actually test, you'll have to put code in the test harness to test the expected outcomes for the various circumstances that you expect your handler to work with.

     

    Comment

    • Anuj Behl

      Hi Natraj,

      How is your CPM triggered? What object did you create the CPM on? It would be hard to tell without the details.

      Could you also share your use case? It might be possible that your functionality could be achieved without using CPM.

      -Anuj

    • Scott Harwell

      This isn't in your test harness, correct?  Test harness data is rolled back; it will never be in your DB.

      Are you able to successfully run your test harness and check for the data that you're attempting to create?  Is it successful and the issue only arises when deployed?

      Are you able to take action without your custom script...moving the logic to the CPM to rule out any include issues first?

    • Mark Rhoads

      Also, the commit is not necessary with CPM.

      And, if the CPM is creating the same Contact user each time, then it might be getting a "duplicate contact" error?

       

    • Natraj Buddi

      Hi Anuj,

      My use Case is that i need to create contact by using a custom script, i have written script initially by hard coding the field values to test whether i can create new contact or not..

      I Am testing this in Process Manager   by clicking on Test button.

      Note: I am doing this on my Demo Instance provided by Oracle.

      Please let me know is there an issue with my script, i am sharing my full script.

    • Barrilito van Dijk

      Hi Natraj,

      You should define your contact email address like this:

       
      

      $contact->Emails = new RNCPHP\EmailArray();

      $contact->Emails[0] = new RNCPHP\Email();

      $contact->Emails[0]->AddressType=new RNCPHP\NamedIDOptList();

      $contact->Emails[0]->AddressType->LookupName = "Email - Primary";

      $contact->Emails[0]->Address = "yourname@example.com";

       

      Regards.

    • Natraj Buddi

      Hi Scott,

      Thanks for the reply, 

      Yes, this is n't in my test harness, above code is in my Apply Class, I am executing this script in my Process Manager by clicking on test button.

      Note: i am working on demo instance provided by Oracle, my Project is starting in next week so i am doing some pocs on client requirements.

    • Anuj Behl

      Since, you are still just testing it, you should assert the outcome in Test Harness rather than searching for the contact in database.

    • Mark Rhoads

      Running a test in the Process Designer does not allow anything to be committed to the database, even if the script contains a commit.

      To actually test, you'll have to put code in the test harness to test the expected outcomes for the various circumstances that you expect your handler to work with.

       

    • Barrilito van Dijk

      Hi Natraj,

      Any progress with all the comments and input given?

      Regards.

    • Dietrik

      I guess you should start by getting your self familiar with the basics of OSC.

    • Natraj Buddi

      Hi All,

      As we could not able to save data in RN database by CPM , i have tried to create new contact by custom Widget.

      I have placed my new contact logic in Model and called that model from my Custom widget controller.It worked.

       

      Thanks,

      Natraj

       

    • Barrilito van Dijk

      Hi Natraj,

      Good to hear you got it working some way. Could you please close this post as your problem was solved, close the post by setting a "best answer" to the best answer, that way everyone can see your problem was solved. Thanks.

      Regards.

    • Natraj Buddi

      But my actual requirement is need to import data from  CSV file to RN database without using import wizard for my custom objects.

      I understand that we do not have physical path to place csv file, so i am trying to upload file to UI .read that file to get the data and do the logic(new records logic) in custom model.

      can any one suggest the ideas to achieve this..

       

      Thanks,

      Natraj

    • Barrilito van Dijk

      Hi Natraj,

      In your orignal post you never said something about a csv import?

    • Natraj Buddi

      Hi Barrilto,

      Apologies for that, as i am new to RightNow first i thought of create new record by custom script.

      Now i am trying to import records from csv file through custom script by using a custom widget.

      Thanks,

      Natraj