Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality

Moderator: amosbatto

Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
#775489
hi

i'm trying to use the wiki to populate a grid from the input documents uploaded by a user in a previous step.

my trigger is as below:

$caseId = @@APPLICATION;
$query = "SELECT C.CON_ID AS url, C.CON_VALUE AS filename FROM APP_DOCUMENT AD, CONTENT C
WHERE AD.APP_UID='$caseId' AND AD.APP_DOC_TYPE='INPUT' AND AD.APP_DOC_STATUS='ACTIVE'
AND AD.APP_DOC_UID=C.CON_ID AND C.CON_CATEGORY='APP_DOC_FILENAME' AND C.CON_VALUE<>''";
$result = executeQuery($query);
if (is_array($result) and count($result) > 0) {
@@DocumentListGrid = json_encode($result);
@@urlList = json_encode($result);
}
@@sAccounts = json_encode($result);

and my javascript code is

var grd = getObject("dl");
//remove all existing rows in the grid (except the first one):
var norows = Number_Rows_Grid("dl", "filename");
for (var i = norows; i > 1; i--){
grd.deleteGridRow(i, true);
}
//unserialize the hidden field as an object:
var oAccounts = eval("(" + getField("sAccounts").value + ")");
//echo oAccounts;
for (var rowNo in oAccounts) {
if (rowNo != 1)
grd.addGridRow();
getGridField('dl', rowNo, 'filename').value = oAccounts[rowNo]["filename"];
getGridField('dl', rowNo, 'url').href = oAccounts[rowNo]["url"];


the grid is called "dl" in the dynaform which points to "DocumentListGrid".

whilst the trigger seems to work, i get syntax errors from the java in the form and it only disappears when i comment out the "eval" line.

anyone any ideas? this is driving me nuts.

ade
Last edited by artemis on Thu Dec 19, 2013 5:47 am, edited 1 time in total.
By artemis
#775721
ok.

managed to get this to work without using eval.

Utilising the info here http://wiki.processmaker.com/index.php/ ... _DynaForms with regard to creating the DocumentListGrid but don't bother with urlList or the JS example as on my system it wouldn't work with the 'eval' option.

changed the trigger to be as follows...

$caseId = @@APPLICATION;
$query = "SELECT C.CON_ID AS url, C.CON_ID AS url2, C.CON_VALUE AS filename FROM APP_DOCUMENT AD, CONTENT C
WHERE AD.APP_UID='$caseId' AND AD.APP_DOC_TYPE='INPUT' AND AD.APP_DOC_STATUS='ACTIVE'
AND AD.APP_DOC_UID=C.CON_ID AND C.CON_CATEGORY='APP_DOC_FILENAME' AND C.CON_VALUE<>''";
$result = executeQuery($query);
if (is_array($result) and count($result) > 0) {
for ($i = 1; $i <= count($result); $i++){
$result[$i]['url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/sys' . @@SYS_SYS . '/' .
@@SYS_LANG . '/' . @@SYS_SKIN . '/cases/cases_ShowDocument?a=' . $result[$i]['url2'];
}
@=DocumentListGrid = $result;
}

NOTE changed the sql query to extract the url twice (i.e. 'url' and 'url2'). This is so i can manipulate the $result variable when constructing the link.

The extract pulls out all input documents for the case and rebuilds the $result array by changing the $result{x}['url'] field.
the @=DocumentListGrid variable is then automatically populated with the filename of the document as well as the correct url to open it.

Ran the trigger before the dynaform loads and data is automatically dropped into the grid.

It may be that the 'eval' function works for you but this seems to be a simpler solution with less js in the form itself.

Ade
Task doesnt have any users.

The first problem is that you need to use = = in[…]

Just guide me to implement this?

Hi, I have a text control (rfq_segment) and I wan[…]

Genial!!! gracias. :D i need to translate an[…]