Share ideas, ask questions, and get feedback about developing for ProcessMaker

Moderator: amosbatto

Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By Pradeep
#3687
Hi..!

If we have a grid with multiple columns and rows, how can we access the field value of a particular row and column and use that value while writing derivation rules.

Is there any function to retrieve number of rows in a grid.

Thanks in advance

Pradeep
User avatar
By amosbatto
#3786
Sorry that it took me so long to get around to answering this one.

If you have a grid object named "Items" in the master form and it contains the field "Cost", then you can access the first and second rows in the grid like this in a trigger:
Code: Select all
$CostInFirstRow = @=Items[1]['Cost'];
$CostInSecondRow = @=Items[2]['Cost'];
Note that the grid starts counting from 1, and not 0 like a normal array. If you try to access Items[0]['Cost'] you will get a NULL value. Make sure to embed the grid form in a master form. Note that I use @= (instead of @@) to access the variable because I don't want to add quotes to it.

If you want to sum the cost field you could do it like this:
Code: Select all
$lenGrid = count(@=Items);
@=sumGrid = 0; 
for ($x = 1; $x <= $lenGrid; $x++)
    @=sumGrid += @=Items[$x]['Cost'];
Nonetheless, it isn't necessary to write php code to do this. ProcessMaker will automatically sum a column in a grid if you add the option function="sum" to the XML definition of the field in the grid form. Here is the sample XML code for a field named "Cost":
Code: Select all
<Cost type="text" maxlength="64" validate="Real" size="1" mode="edit" function="sum" mask="" strto="" required="0" readonly="0" dependentfields="" defaultvalue="" sqlconnection="" savelabel="0">  <en>Cost</en>
</Cost>
In the master grid form, the sum will automatically be calculated and displayed below the embedded grid object. (To see an example of this and some javascript to control grid objects, download the process "JS Examples" from http://library.processmaker.com)
ProcessMaker will automatically create a variable called @=SYS_GRID_AGGREGATE_Items_Cost which you can access from triggers or in subsequent DynaForms if you create a Textbox with the same name.
By fiqihpunya
#826377
amosbatto wrote: Sun Sep 06, 2009 7:05 am Sorry that it took me so long to get around to answering this one.

If you have a grid object named "Items" in the master form and it contains the field "Cost", then you can access the first and second rows in the grid like this in a trigger:
Code: Select all
$CostInFirstRow = @=Items[1]['Cost'];
$CostInSecondRow = @=Items[2]['Cost'];
Note that the grid starts counting from 1, and not 0 like a normal array. If you try to access Items[0]['Cost'] you will get a NULL value. Make sure to embed the grid form in a master form. Note that I use @= (instead of @@) to access the variable because I don't want to add quotes to it.

If you want to sum the cost field you could do it like this:
Code: Select all
$lenGrid = count(@=Items);
@=sumGrid = 0; 
for ($x = 1; $x <= $lenGrid; $x++)
    @=sumGrid += @=Items[$x]['Cost'];
Nonetheless, it isn't necessary to write php code to do this. ProcessMaker will automatically sum a column in a grid if you add the option function="sum" to the XML definition of the field in the grid form. Here is the sample XML code for a field named "Cost":
Code: Select all
<Cost type="text" maxlength="64" validate="Real" size="1" mode="edit" function="sum" mask="" strto="" required="0" readonly="0" dependentfields="" defaultvalue="" sqlconnection="" savelabel="0">  <en>Cost</en>
</Cost>
In the master grid form, the sum will automatically be calculated and displayed below the embedded grid object. (To see an example of this and some javascript to control grid objects, download the process "JS Examples" from http://library.processmaker.com)
ProcessMaker will automatically create a variable called @=SYS_GRID_AGGREGATE_Items_Cost which you can access from triggers or in subsequent DynaForms if you create a Textbox with the same name.
Hallo, amosbatto, i have a grid with 14 columns, and i try to import excel file to grid within 60 rows of data, and then when i try to input that grid values into database, only a portion of it entered.

How did it happen?
User avatar
By amosbatto
#826387
fiqihpunya wrote: i have a grid with 14 columns, and i try to import excel file to grid within 60 rows of data, and then when i try to input that grid values into database, only a portion of it entered.

How did it happen?
max_input_vars is probably limiting the number of input fields that you can save from the Dynaform.
Edit your php.ini file and add these settings:
Code: Select all
max_input_vars = 10000
memory_limit=512M
post_max_size = 100M
upload_max_filesize = 100M
max_file_uploads = 300
After modifying these settings, restart Apache.

Does that fix it?
By fiqihpunya
#826407
amosbatto wrote: Fri Sep 06, 2019 6:05 pm
fiqihpunya wrote: i have a grid with 14 columns, and i try to import excel file to grid within 60 rows of data, and then when i try to input that grid values into database, only a portion of it entered.

How did it happen?
max_input_vars is probably limiting the number of input fields that you can save from the Dynaform.
Edit your php.ini file and add these settings:
Code: Select all
max_input_vars = 10000
memory_limit=512M
post_max_size = 100M
upload_max_filesize = 100M
max_file_uploads = 300
After modifying these settings, restart Apache.

Does that fix it?
it was fixed, thank amos<<
Task doesnt have any users.

I have created a small process. Users are assigned[…]

NEW MOBILE APP ISSUE

Just trying to setup to use the mobile App with my[…]

It's really a great idea. I have followed the seco[…]

yes i use php thanks for the information