Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#788614
Let's say you want to generate report for Process A,

1. Create another process, with Start Timer event consisting of a single Task named "Generate Report".
2. Configure the start timer to start every day on a particular time of your choice.
3. Create a trigger with the following code:
Code: Select all
$date = date('Y-m-d', strtotime("now"));
$prev = date('Y-m-d', strtotime("-1 day"));
$pro ='xxxxxxxxxxxxxxxxxxxx'; //Replace with Id of Process A
$res = executeQuery("select USR_UID, TAS_UID, APP_UID, DEL_THREAD_STATUS from APP_DELEGATION 
  where PRO_UID='$pro' and DEL_DELEGATE_DATE < '$date' and DEL_DELEGATE_DATE > '$prev' ");
 @=info = array(); //create a grid Variable @=info
 $i=1;
if(is_array($res))
{
foreach($res as $row)
{
  $user = userInfo($row['USR_UID']);
  @@name = $user['firstname'] .' '. $user['lastname'];
  $t = new Task();
 $aTask = $t->Load($row['TAS_UID']);
 @@taskTitle = $aTask["TAS_TITLE"];
 //Add variables to store other info
      @=info[$i] = array(
         'firstName' => $name,
         'lastName'  => $taskTitle,
         'status'       => $row['DEL_THREAD_STATUS']
      );
      $i = $i+1;
}  
}
4. Create an output document, which displays the information stored in grid.
5. Now create another trigger to fire after the first one which generates the output document and sends it via email:
Code: Select all
$outDocId = 'xxxxxxxxxxxxxxxxxxxxxxxx'; //Replace with your Output Document UID
PMFGenerateOutputDocument($outDocId); 

//retrieve info from the database about the generated output document file
$query = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND
   DOC_UID='$outDocId' AND APP_DOC_STATUS='ACTIVE'";
$result = executeQuery($query);
 
if (!is_array($result) or count($result) == 0) {
   die("Error: Unable to find generated Output Document in database.");
}
 
$d = new AppDocument();
$aFile = $d->Load( $result[1]['APP_DOC_UID'] );

//change from 'http://' to 'https://' if using SSL
//change 'pdf' to 'doc' for MS Word file
@@outDocUrl = 'http://' . $_SERVER['SERVER_NAME'] .
   // ':' . $_SERVER['SERVER_PORT'] . //uncomment if needing a port number
   '/sys'. @@SYS_SYS . '/en/neoclassic/cases/cases_ShowOutputDocument?a=' .
   $aFile['APP_DOC_UID'] . '&v='. $aFile['DOC_VERSION'] . '&ext=pdf';
6. In the above trigger add PMFSendMessage() to send an email which contains the link to the output document generated. For this create an email template with @@outDocUrl variable which contains the link to the generated document.

I haven't tested the above code, but I hope you get the idea.

One more thing, configure timereventcron.php to run everyday, so that the Start Timer event is initiated properly.
#813565
amosbatto wrote:Zainab, Thanks for answering this one. Now I can go home happy for the weekend!

PS: I took the liberty of editing your code to fix a few minor things that would have stopped it from running (missing semicolons, missing quotation marks, etc.)
Hi Amos and Zainab, could you send me your processes for making daily report? (process A and generate daily report process)

Thanks alot :D
#813582
sofiathefake wrote: Hi Amos and Zainab, could you send me your processes for making daily report? (process A and generate daily report process)

Thanks alot :D
Neither of us created a process to test this. Zainab wrote out some code and posted it and I spotted some errors in the code and fixed them. You will have to follow the instructions posted here and test it.
#813641
zainab wrote:Let's say you want to generate report for Process A,

1. Create another process, with Start Timer event consisting of a single Task named "Generate Report".
2. Configure the start timer to start every day on a particular time of your choice.
3. Create a trigger with the following code:
Code: Select all
$date = date('Y-m-d', strtotime("now"));
$prev = date('Y-m-d', strtotime("-1 day"));
$pro ='xxxxxxxxxxxxxxxxxxxx'; //Replace with Id of Process A
$res = executeQuery("select USR_UID, TAS_UID, APP_UID, DEL_THREAD_STATUS from APP_DELEGATION 
  where PRO_UID='$pro' and DEL_DELEGATE_DATE < '$date' and DEL_DELEGATE_DATE > '$prev' ");
 @=info = array(); //create a grid Variable @=info
 $i=1;
if(is_array($res))
{
foreach($res as $row)
{
  $user = userInfo($row['USR_UID']);
  @@name = $user['firstname'] .' '. $user['lastname'];
  $t = new Task();
 $aTask = $t->Load($row['TAS_UID']);
 @@taskTitle = $aTask["TAS_TITLE"];
 //Add variables to store other info
      @=info[$i] = array(
         'firstName' => $name,
         'lastName'  => $taskTitle,
         'status'       => $row['DEL_THREAD_STATUS']
      );
      $i = $i+1;
}  
}
4. Create an output document, which displays the information stored in grid.
5. Now create another trigger to fire after the first one which generates the output document and sends it via email:
Code: Select all
$outDocId = 'xxxxxxxxxxxxxxxxxxxxxxxx'; //Replace with your Output Document UID
PMFGenerateOutputDocument($outDocId); 

//retrieve info from the database about the generated output document file
$query = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND
   DOC_UID='$outDocId' AND APP_DOC_STATUS='ACTIVE'";
$result = executeQuery($query);
 
if (!is_array($result) or count($result) == 0) {
   die("Error: Unable to find generated Output Document in database.");
}
 
$d = new AppDocument();
$aFile = $d->Load( $result[1]['APP_DOC_UID'] );
[url=http://www.rachat-de-credit-simulation.com/regroupement-de-pret] Regroupement de prêt [/url]	
//change from 'http://' to 'https://' if using SSL
//change 'pdf' to 'doc' for MS Word file
@@outDocUrl = 'http://' . $_SERVER['SERVER_NAME'] .
   // ':' . $_SERVER['SERVER_PORT'] . //uncomment if needing a port number
   '/sys'. @@SYS_SYS . '/en/neoclassic/cases/cases_ShowOutputDocument?a=' .
   $aFile['APP_DOC_UID'] . '&v='. $aFile['DOC_VERSION'] . '&ext=pdf';
6. In the above trigger add PMFSendMessage() to send an email which contains the link to the output document generated. For this create an email template with @@outDocUrl variable which contains the link to the generated document.

I haven't tested the above code, but I hope you get the idea.

One more thing, configure timereventcron.php to run everyday, so that the Start Timer event is initiated properly.
Thank you for your response, it is so helpful :)
#813689
See the attached process that create a daily report from the data queried from sql and add it to the dynaform. After you click submit, next trigger create csv file and adds it to the input document. Finally the last trigger send the link as an email, I was not able to attach the file in the email.

You need to create info (grid variable), name, emailVariable and csvFileUrl variables.

You can change the process to auto start, remove the dynaform in the steps. That way you the receiver will get an email at the end of every day.
Attachments
(8.73 KiB) Downloaded 296 times

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]