Customer Portal

Get Involved. Join the Conversation.

Topic

    Pramod Vasudeva Murthy
    PDF generation in CPMAnswered
    Topic posted February 17, 2018 by Pramod Vasudeva MurthyBlack Diamond: 60,000+ Points 
    376 Views, 25 Comments
    Title:
    PDF generation in CPM
    Content:

    Hi folks,

    I am trying to generated PDF using CPM. I know we can go with Addins which is little easier compared to CPMs, but I cant due to various other reasons.

    I am trying with these two libraries:

    • tcpdf
    • fpdf

    tcpdf has the format I want, which takes in html as a parameter and converts to PDF.

    But the problem is, no file operations are allowed in CPM no file_get_contentst(), file_read, file_write() etc.

    So,

    • How do we get them working?
    • Can I call a custom script and generate them from CPM?

    TIA,

    Pramod V

    Version:
    17D

    Best Comment

    Gursimran Singh Saini

    Ooh that complicates it.

    Here's what I would do:

    1. One Sync CPM to check $obj and $obj->prev. At the end of this CPM, set a field value to something.

    2. One Async CPM which has the cURL call to Custom Script.
    This CPM will be triggered through business rules.
    When Field (Field modified in step 1) Modified this Edit, then Execute CPM
    If this is Incident CPM, then you can even add another condition: If Incident Updated from Public API -> Customised Process.

    Comment

    • Pramod Vasudeva Murthy

      I have another problem.

      In async I dont have access to $obj->prev, it's only avail in synch CPMs.

      I need to compare previous status value and current status value and Send SMS via CPMs.

      ~VIP

       

    • Gursimran Singh Saini

      Ooh that complicates it.

      Here's what I would do:

      1. One Sync CPM to check $obj and $obj->prev. At the end of this CPM, set a field value to something.

      2. One Async CPM which has the cURL call to Custom Script.
      This CPM will be triggered through business rules.
      When Field (Field modified in step 1) Modified this Edit, then Execute CPM
      If this is Incident CPM, then you can even add another condition: If Incident Updated from Public API -> Customised Process.

    • Pramod Vasudeva Murthy

      Or from the rules itself we can check if previous value not equal to current and trigger asynch CPM directly?

      ~VIP

    • Gursimran Singh Saini

      Checking previous value is only possible in Incident.Status, Incident.Assigned and Incident.Group.

      So if you are working on one of these three fields, then yes, you can use Business Rules.

    • SAJI MATHEW

      Hi

      You can call the custom script from CPM, below is the code snippet

      public static function apply( $run_mode, $action, $obj, $n_cycles )
      {
         try
        {
      require_once( get_cfg_var( 'doc_root' ).'/custom/cpm_incident_handler.php');
      $incidentEventHandlerObj = new \IncidentEventHandler($obj,$action);
       
        }
         catch (Exception $err)
        {
      echo $err;
        }
        return;
       
      Here 'IncidentEventHandler' is class written in custom script cpm_incident_handler.php
    • Pramod Vasudeva Murthy

      We achieved this using fpdf libraries. Marking Gurusimran's answer as he guided me to closure.

      ~VIP

    • Justin

      i thought this may be helpful as well

      https://github.com/RelaxedJS/ReLaXed

       

       

    • Pramod Vasudeva Murthy

      File operations in JS feels weird. It has to be done by Server I feel.

      ~VIP

    • Saravanan Sekar

      HI Gursimran,

       

      Is that dl('curl_php5.so') is mandatory to load curl, because am using the curl functionality for integrations as of now without using that library.

       

      Thanks,

      ~ S.Saravanan

    • Gursimran Singh Saini
      Saravanan Sekar said:

      HI Gursimran,

       

      Is that dl('curl_php5.so') is mandatory to load curl, because am using the curl functionality for integrations as of now without using that library.

       

      Thanks,

      ~ S.Saravanan

      View original

      Uh no. It was required in old versions I guess.

      I just haven't stopped using it.

      The CPM has to be Async. Then cURL works.