Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Value of subform field. Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Value of subform field.

Unread post by treed »

Hello I have a 2 tiered pricing system and need to look up the quantity value to determine the pricing. This is done in a subform grid. The lookup table has a product small order price a min order quantity and a normal price. Right now the price is placed in the form from a lookup of product code after browse.
Screenshot from 2022-05-26 10-41-26.png
What I'm trying to do is something like this:
$lu = nuLookupRecord();

if (#OrdLineQty#<$lu->ProdWholeSaleMinQty)
{
nuSetFormValue('OrdLineRate', $lu->ProdSmWholeSale);}
else {
nuSetFormValue('OrdLineRate', $lu->ProdWholeSale);}
nuSetFormValue('OrdLineDesc', $lu->ProdDesc);

However I can see that hashcookies for subform objects are not available. Any suggestions on how to proceed?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Value of subform field.

Unread post by kev1n »

Hi,

Add an onclick event to your lookup object to set a Hash Cookie that can be used in After Browse:

Code: Select all

var qty = nuSubformRowObject(event.target.parentElement.id, 'OrdLineQty').val();
nuSetProperty('OrdLineQty', qty);
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Value of subform field.

Unread post by treed »

Thank you!
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Value of subform field.

Unread post by treed »

There seems to be a browser issue in Brave (my preferred browser), but things work fine in FireFox. What I'm finding is that the property is not always set. I'm seeing this through the console.
Screenshot from 2022-06-08 15-19-09.png
I'm assuming that the error is caused by the above, if not please let me know. FF reports no errors. Any idea how to resolve this?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Value of subform field.

Unread post by kev1n »

This is not an error but an "improvement issue" that is caused by the external library Google chart.
I tried to replicate your issue using Brave but was not able to do so.

What I did was set a Hash Cookie with nuSetProperty('#OrdLineQty#','someting') in a lookup's onclick event.
In the After Browse event I output it with nuDebug('#OrdLineQty#');

What you could do is a console.log() after setting the Hash Cookie to output its value to the console. This is to watch if is actually being set.

Code: Select all

nuSetProperty('OrdLineQty', qty);
console.log('OrdLineQty: ', qty);
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Value of subform field.

Unread post by treed »

I did set a console.log. When it was set, things it worked, when it wasn't it didn't. It seems to work randomly mainly on new records. This is Brave on Ubuntu 22.04.
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: Value of subform field.

Unread post by treed »

Got an update to Brave yesterday and it seems to work fine now.
Post Reply