Editable Grid - Calculation

Hello.

I have a master form which uses a editable grid for the “Master/Detail Form”.

On the editable grid I want to do a basic calculation…

There is a lookup that retrieves a field called “Bags per Case” from the master form table.

Then in the Editable Grid I do the following formula…

sc_lookup(dataset, “select orderID, SHIPPING_bags_per_case from tb_byob_orders where orderID=’{orderID}’” );
[result] = {dataset[0][1]};

{VESSEL_cases_shipped} = {VESSEL_qty_shipped_planned} / [result];

The SC_Lookup gets me the right value (10) but I can’t get the formula in the editable grid to work and fill in the “Cases Shipped” field ?

Whats wrong here?

Master-Detail.jpg

Have you examined both the contents of all the variables before and after the calculation?

Also, does [result] need to be a global variable? Have you tried it as just a local PHP variable?

e.g.

$result = {dataset[0][1]};

{VESSEL_cases_shipped} = {VESSEL_qty_shipped_planned} / $result;

I saw similar example in http://www.scriptcase.net/watch-scriptcase-video-courses/ in Nested Grids video or in other related to grid. You need to update fiield in Master Form when value will be changed in Detail form, right ?

Thank You very much for your helpful reply,

If I assign the field to a global variable, and then use the global variable in my formula I think my problem would be solved. However is their a particular place inside Scriptcase where I would be able to assign fields to variables. I’ve had a look inside the Application section and their is a sub-section titled Global Variables but that only seems to list the global variables declared elsewhere.