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.
#817201
Hi,

Grateful if somebody can give me a hand to tackle the following problem in dynaform.

I have a table PMT_COMPANY indexed by COID for storing company information such as name (CONAME), address, etc.

I have another table PMT_VIP indexed by VIPID holding the information of the VIPs. This table contains a column VIPCOID holding the company key (COID) of the VIP for linking up the PMT_VIP and PMT_COMPANY.

In a dynaform, I have a field @@CoName of Suggest Control type which access to the PMT_COMPANY for company selection.
The SQL
SELECT CONAME, CONAME FROM PMT_COMPANY LIMIT 999
works well.

A dependent field @@CoID which the SQL
(SELECT COID, COID FROM PMT_COMPANY WHERE CONAME = @@CoName) in the sql Property
could get the COID successfully from the PMT_COMPANY.

In the same dynaform, I created a grid for the purpose of listing the VIPs of the selected company and their phone numbers and other information for my colleagues to select the VIPs (can be more than one) of the selected company for them to follow-up with. The columns of the grid are as follows.

VIPName (Suggest type) , Tel (Text type), other fields (all are of Text type)

The Tel other fields are dependent fields depending on the VIPName.

In the VIPName column, I used the following SQL in the sql Property trying to get the list of VIP names from the PMT_VIP.

SELECT VIPNAME, VIPNAME FROM PMT_VIP WHERE VIPCOID =@@CoID

I found out that the @@CoID is null in the grid and the SQL could not come up with any result.

Could the value of a dependent field carry forward into grid?

Grateful if I can be advised on how to fix the problem.

Thousand Thanks in advance.

cheers,
Karl
#817377
Hello Kleung,

As you can see on the wiki page: https://wiki.processmaker.com/3.0/Depen ... side_Grids, It is not possible to set dependency between a web control and a grid column, because of the difference between both data structures.

If you want that the "VIPName (Suggest type)" store the value of the "@@CoID" field, you have to do that using Javascript.

Here is a code example of how you could do that:
Code: Select all
$('#CoID').setOnchange(function(){
	var var1 = $('#CoID').getValue();
	$('#gridVar001').setValue(var1,1,1);
});
Change the "#gridVar001" value with the ID of the grid in your Dynaform and also change the position in which is the suggest control.

I hope it helps you to clarify your doubts.

Best regards.
#817380
Hi andreaadamczyk ,

Thank you for your kind attention.

I'm sorry that your suggestion did not work.

I tested with the following three arrangements.
1) I created a VIPGrid with the following columns.
VIPName (Suggest type) , Tel (Text type)

Your advised javascript was added to the dynaform.
$('#CoID').setOnchange(function(){
var varl = $('#CoID').getValue();
$('#VIPGrid').setValue(varl,1,1);
});

and the sql Property of VIPName was set with the SQL
SELECT VIPNAME, VIPNAME FROM PMT_VIP WHERE COID = @@CoID

I found out that the @@CoID is still null in the grid and the SQL could not come up with any result.

2a) I tried to add a column to show the CoID in the grid. The VIPGrid then became
VIPName (Suggest type) , Tel (Text type), CoIDhidden (Text type)

I changed the javascript to
$('#CoID').setOnchange(function(){
var CoIDhidden = $('#CoID').getValue();
$('#VIPGrid').setValue(CoIDhidden, 1, 3);
});

and the sql Property of VIPName was set with the SQL
SELECT VIPNAME, VIPNAME FROM PMT_VIP WHERE COID = @@CoIDhidden

The value of the CoID could not be shown in the CoIDhidden column and the value of @@CoIDhidden in the SQL was still null.

2b) I changed the javascript a little bit to
$('#CoID').setOnchange(function(){
var varl = $('#CoID').getValue();
$('#VIPGrid').setValue(varl, 1, 3);
});

The value of the CoID still could not be shown in the CoIDhidden column and the value of @@CoIDhidden in the SQL was still null.

Grateful if you can advise me what's wrong with my codes.

Thousand Thanks

cheers,
Karl
#817389
Hello Karl,

In the option 2b) you could use a textbox instead of a hidden field, and you can hide the textbox column using the function hideColumn(), for more information about this function see: https://wiki.processmaker.com/3.0/JavaS ... hideColumn.

Then you could use the query "SELECT VIPNAME, VIPNAME FROM PMT_VIP WHERE COID = @@CoIDhidden" on the suggest control.

Please, let me know if this works for you.

Best regards.
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[…]