Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everybody
I need to find a way to make a variable changes depending of the object in which this is deployed,
The problem is that I need to use the same variable for different objects but these have different dimensions
for example:
if( $(vObjectID)=1, // or something like this
sum(total {$<FLAGP={1}, >}SALDO) ,
sum(total <AnioMes> SALDO) )
Best Regards
You need to 2 variables.
If just set expression is changing the following should do:
sum(total $(var1)SALDO)
sum(total $(var2)SALDO)
Any specific reason why you cannot have customized expressions in different objects?
The expession is into a variable in script and this is chained many times with many others variables:
Let vSaldo =
if( $(vObjectID)=1, // or something like this
sum(total {$<FLAGP={1}, >}SALDO) ,
sum(total <AnioMes> SALDO) );
Let vTotal = $(vSaldo) + $(vOtherVariables);
IMHO this is a different problem. I read the first one as: "is there a method to get the object ID in an expression so that it can be adjusted according to the object where it is used". Don't know the answer to that. There is an (undocumented) function called GetActiveSheetId, maybe there is also one that returns the active object ID.
The second question is about how to store expressions into variables for later use. You can do that like this:
LET vSaldo = '=IF ($' & '(vObjectID) = 1, sum(total {$<FLAGP={1}, >}SALDO) , sum(total <AnioMes> SALDO) );';
If you want to manipulate the content of this variable later on, you have to make sure that $-substitution is NOT performed on variable $(vObjectID) in the script already. Otherwise your expression becomes broken.
A solution for that is to use another character instead of the dollar sign, and replace the replacement character during the very last assignment, e.g.
LET vSaldo = '=IF (§(vObjectID) = 1, sum(total {$<FLAGP={1}, >}SALDO) , sum(total <AnioMes> SALDO) );';
LET vSaldo2 = '$(vSaldo)' & ' + 1000';
LET vTotal = Replace('$(vSaldo2)', '§', '$'); // No script manipulations anymore after this statement.
Best,
Peter