Jump to content

How to get the current WSSubrow?

Recommended Posts

When I have a worksheet script running in a particular column, I want the script to know whether it's the first subrow or not.

That's because I want a calculation to run only once, even though there are many objects in the list. But since I already calculated the necessary value in the first subrow in the rest of the subrows I just want to get the value from the first subrow.


I'm imagining something along these lines

if (WSSubrowCurrent==1):

Of course GetWSSubrowCellValue would require the current row and column, which brings me back to: how do I get the current row, column and subrow?

I'm not seeing any VS command in the dev wiki to accomplish this. Does anybody have good ideas?

Link to comment

My vague understanding is that a change was made a few Vw versions ago in how database rows were built. I think now the rows don't actually exist until after the full calculation for all rows is completed, so there is no way to know when the first row is calculating.


An alternative approach you could try, is do define the worksheet row formula yourself (example below) then use the following for the DB row formula:




I have no idea if this would work, but might be worth playing with. Note that the first handle found is not influenced by the sort order of the worksheet, but the creation order of the items found by the criteria you enter, in the document.



{ the script - add something like this to a script in a script palette called LoadDBRow. Sorry I don't know Python so this is VS }

Procedure LoadDBRow;


    gb1 : BOOLEAN;

Procedure DoIt(h1 HANDLE);


    IF NOT gb1 THEN DoMyCalculationAndLoadCell; { load a spare cell with the first row calculation (done here), then use that cell in your column formula }

    gb1 := True;




    gb1 := False;

    ForEachObject(DoIt, <insert your criteria here>);

    ClearTheCell; { empty out the spare cell }



  • Like 1
Link to comment

I agree with Julian, it is not possible to get the subrow. I filed the following Enhancement Request in August of 2020.



Currently in a worksheet script there is no way to access the data in other columns for the specific subrow the script is accessing.

In my current use case, a customer wants to create a formula in a worksheet based on object parameters and do a calculation. They then want that value stored in a Record.Field.

I do not have a way to access the data in other cells in the subrow, so the calculation has to be done (or redone) in the worksheet script. If I could just access say "Column C" then the user could change the formula and the worksheet script would only have to store that value into the field.

There are many other cases where the ability to access the other columns of data in the worksheet would be useful in a script instead of having to go an recollect that data directly from the subrow referenced object.


  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...