Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By HSaber
#815909
Hello,

Am kinda new to the ProcessMaker and I would like to get some help regarding the issue am facing right now

I would like to get the current user and put it in the name field in the grid for every step and after that, I want to get the data that was inserted into the grid to be viewed to an output document I designed later.

I have attached a picture of the form and the output document

I have 6 steps in which the username will be captured and inserted into the name field, and the final result will be printed out using the output document.
Attachments
1.jpg
1.jpg (25.69 KiB) Viewed 4708 times
2.jpg
2.jpg (35.01 KiB) Viewed 4708 times
By HSaber
#815915
Hi,

I have tried to use this code directly in the Dyna form javascript editor but still, it doesn't work also tried using a trigger but again with no luck

$aUser = PMFInformationUser(@@USER_LOGGED);
@@UserName = $aUser['firstname'] . ' ' . $aUser['lastname'];

$("#grd_DeptApproval").setValue(@@UserName, '1', '2');
User avatar
By amosbatto
#815924
The easiest way to do this is to add a @@UserName variable to the default value property of your "Name" field, like this:
defaultValueGridField.png
defaultValueGridField.png (21.34 KiB) Viewed 4698 times
Then set this trigger to execute before the DynaForm:
Code: Select all
$aUser = PMFInformationUser(@@USER_LOGGED);
@@UserName = $aUser['firstname'] . ' ' . $aUser['lastname'];
User avatar
By amosbatto
#815925
Also change the field to "view" mode if you don't want the user to be able to change the value.
By HSaber
#815933
Thanks! for your kind reply amosbatto, but I have tried out your solution but it doesn't work, do you have any idea what went wrong.
User avatar
By amosbatto
#815953
Oh, I see the problem. When it is a system variable, the "default value" property works in grids, but when it is a normal case variable, it doesn't seem to work. I've attached a process that shows a workaround.
(28.22 KiB) Downloaded 284 times
You have to use this JavaScript code to set the value in the grid field:
Code: Select all
var oGrid = $("#productsGrid");
var nRows = oGrid.getNumberRows();
var nameFieldColNo = 2; //set to the column number of the "Name" field
var userName = $("#UserName").getValue();

//set user's name in any existing grid rows that are blank when form loads:
for (var i = 1; i <= nRows; i++) {
  if (oGrid.getValue(i, nameFieldColNo) == '') {
    oGrid.setValue(userName, i, nameFieldColNo);
  }
}

//set user's name in new rows when added to the grid:
oGrid.onAddRow(function(aNewRow, oNewGrid, rowIndex) {
  oGrid.setValue(userName, rowIndex, nameFieldColNo);
});
By HSaber
#815956
Thank! you very much this really worked as a charm now the only thing remaining for me is how to prohibit the user in the next step from editing the previous rows in the grid.
By HSaber
#815970
amosbatto wrote: Thu Sep 06, 2018 6:03 pm
HSaber wrote:Thank! you very much this really worked as a charm now the only thing remaining for me is how to prohibit the user in the next step from editing the previous rows in the grid.
I wrote up some documentation for this problem:
https://www.pmusers.com/index.php/Make_ ... _read-only
That's great thanks for the great help amosbatto you're awesome. one last thing I need to ask you how can I compare between 2 date pickers, I have a field called Submission Date and another one called Travel date and I need to not allow the user to enter an old date in the travel date field than the one entered in the Submission date so it should accept dates only higher than the date in the Submission date but not before.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]