Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
workflows function expression
#1
i have a webform that sends a new contact to corebos
inside the data of the contact i have put a variable that is the contact_no -> CONTACTO_XXX
from this fiel i wan to create a workflow that setup another field that is a contact related fiel that has
the first field contact_no

i had been trying without success a lot of time and i cant find the solution

this is the expression of the workflow that dont works now
cf_1236 -> is the related contact that i want to update
cf_1234 -> this is the CONTACT_XXX thas is allready filled

cf_1236 = $(cf_1234 : (Contacts) contact_no)
Reply
#2
Hi

you have to set the ID of the record, not the Contact Number field: contacted

You can do that either by changing the webform to send the internal ID instead of the number or using the new getIDof() workflow expression function.

https://github.com/tsolucio/corebos/blob....php#L1466
Joe
TSolucio
Reply
#3
thanks Joe, one of the options that i managed was to make a business map atached to a query that searches de contact id tor the incoming contatc_no and updates that field, but with that function you have implemented seems easyer
thanks, i am gonna try it :-D

ups... seems that that function its not availabele yet in the system
do i need to upgrade the full system or there its an option to only
upgrade workflows functions enhancements?
Reply
#4
have to do the whole thing: be careful https://blog.corebos.org/blog/denormrelease
Joe
TSolucio
Reply
#5
i must to start working with the denormrelease but in this case
i had found a fast solution that is sending the id of the contact
directly form the form and now in the workflow it can attach
the relacted contact directly as I wanted

so for me to understand, from now on the released is denormalized as master?
if i want to upgrade i must denormalize the database first?
Reply
#6
yes, correct, going forward the denormalization project is part of corebos
Joe
TSolucio
Reply
#7
note that denormalizing is an optional choice

you can upgrade and not activate denormalization on any module, everything will keep working as before and the information will be saved in the same places

the idea is that you denormalize only those modules with a VERY large number of records and only if you need to
Joe
TSolucio
Reply
#8
Muchas gracias Joe por aclararme un poco mas el condepto
creo que va a ser muy util para proyectos con mucho crecimiento
Reply
#9
hello:

I`m trying to create a function based workflow to calculate two fields in a custom module. I configure the workflow like this:

   
   
   
   

And I create a entry in the workflow functions whit this code:


$Vtiger_Utils_Log = true;



require_once 'include/utils/utils.php';

include_once('vtlib/Vtiger/Module.php');

require 'modules/com_vtiger_workflow/VTEntityMethodManager.inc';

global $adb;



$emm = new VTEntityMethodManager($adb);



$emm->addEntityMethod("FacturaComisiones", "calcularCamposFrasComisiones", "flujos_trabajo/HandlerCalcularCamposFrasComisiones.php", "calcularCamposFrasComisiones");





echo 'add Workflow Custom Function calcularCamposFrasComisiones to facturaComisiones module is complete!';

The funtion appears in the list of the workflow configuration in the custom module, but when I try to launch it saving one element , nothig appears. The function contains this code:



function escribirLog($texto, $archivo = "calcularCampos.txt"){

    // una funcion para escribir un log de sucesos...

     $ddf = fopen($archivo,'a');

     fwrite($ddf,"[".date("r")."] $texto\r\n");  

     fclose($ddf);

    //fclose($archivo);    

}





function calcularCamposFrasComisiones($entity) {

    include '../config.inc.php';

    require_once 'include/database/PearDatabase.php';

    

    // se obtiene la id del objeto que vamos a utilizar (en este caso, la ID de la Remesa)

    global $adb, $thesoid;

    $id = $entity->getId();

    $id = explode("x", [i]$id );
[/i]
    $thesoid = $id[1];

    

    escribirLog($thesoid,"calcularCampos.txt" );

    

}

But the log appears empty. If I call the function directly it works...

I don´t know if the function isn´t register, or the problem will be another

Thanbk you
Reply
#10
First, why not just use coreBOS native workflow expressions? You should be able to do everything you need directly there. We haven't been doing custom functions for a long time and the ones we do are REALLY specific and complex things or situations where we want to optimize speed. The workflow language should be powerful enough to do the calculations you need.

I'd say the function is incorrect because you have two different offsets including files:

include '../config.inc.php';
require_once 'include/database/PearDatabase.php';

one of those has to be wrong, because either you are in a subdirectory and can "go up one" to get config.inc in which case the include PearDatabase is going to fail, or you are at the top directory where the code will find Peardatabase but not config.inc

A few notes:

- load vtlib/Vtiger/Module.php, which will load everything you need
- save your logs in the logs directory: it is a security issue to leave them lying around anywhere that they can get downloaded from the internet, the logs director is protected (if you have your apache correctly configured)
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)