Jump to content

Using Table Variable in script


Recommended Posts

I want to access document records in table Doc from many different tables

For that I create a variable $Doc

I want to set the $Doc variable as either: Get(ActiveFieldTableName) & "::" & fkDoc ; or Get(ScriptParameter) & "::" & fkDoc

FM rejects it saying that it can't find the table.  I've tried all sorts of different places to put the " ", without success.

Is there any way I can achieve the desired result?

 

Just in case it is not clear aboe, the Script Parameter would be the calling table name

Link to comment
Share on other sites

4 minutes ago, mdfOffman said:

I want to access document records in table Doc from many different tables

For that I create a variable $Doc

I am not sure how this is supposed to work, and what role the variable is going to play in this.

 

4 minutes ago, mdfOffman said:

I want to set the $Doc variable as either: Get(ActiveFieldTableName) & "::" & fkDoc ; or Get(ScriptParameter) & "::" & fkDoc

If you are doing this in a script, then you must refer to the field using its fully-qualified name, e.g. 

Get(ActiveFieldTableName) & "::" & SomeTO::fkDoc

But this makes no sense, because then the result will look something like:

ActiveTO::123

which doesn't seem useful for anything. You probably want to do:  

Get(ActiveFieldTableName) & "::fkDoc"

to get a result like:

ActiveTO::fkDoc

but this has its its own problems: first, the variable holds a text, not a field reference. And you will be hardcoding the field's name, so your code will break if  it changes. And again, I don't see how having this gets you closer to your stated goal.

 

 

Link to comment
Share on other sites

To clarify my question, I am trying to set the current fkDoc record into the variable $Doc.

But, because this Script will be called from many different tables, I can't hard code the table name into the variable definition.

I can find the table name from Get(ActiveFieldTableName) or by making it the Script parameter.

But FM is insisting that I hard code the table name which means I would have to have more than 30 "If" statements e.g. if Get(ActiveFieldTableName) = "Party Doc" ; $Doc = Party Doc::fkDoc

I'm trying to avoid having more than 30 "if" statements.

Thanks

Link to comment
Share on other sites

1 hour ago, mdfOffman said:

I am trying to set the current fkDoc record into the variable $Doc.

That doesn't really clarify the question. Your attempt seems to be get the name of the field - to be more precise, the fully qualified name of the field in the current layout's table occurrence whose local name is fkDoc.  This could be done using the expression:

Get(LayoutTableName) & "::fkDoc"

Do note that this uses the Get(LayoutTableName) function to get the name of the table of the current layout. The Get(ActiveFieldTableName)function you are trying to use will return a result only when a field has focus - and if that field happens to be a related field, the function will return the name of the related table.

But then the rest of your post suggests you actually want to get the value from that field - so that would be:

GetField ( Get(LayoutTableName) & "::fkDoc" )

I hope this gets you closer to your original goal, although I still don't see exactly how. And I repeat my warning about hardcoding the field's local name.

 

Edited by comment
Link to comment
Share on other sites

  • 3 weeks later...
21 minutes ago, mdfOffman said:

How do I get the Field data from a Portal row?

I am not aware of a function similar to Get(LayoutTableName) for portal fields. I can think of some elaborate workarounds, but ...

If your purpose is to get the field's data, why don't you simply make the field itself the script parameter, without any indirection?

 

Link to comment
Share on other sites

Why can't I get the content of a Portal Field by making that field a button and something like GetField(Get(ActiveFieldContents)) or GetField(Get(ActiveFieldTableName) & "::fkProject") or something like that?

It doesn't pick up the field content /value.

Link to comment
Share on other sites

Because .... (exactly what I just said). We are going in a circle.

If you want the parameter to be the field's value, you won't find a simpler method than making the field itself the script parameter. This is a one-time setting for each button  - and it has the further advantage of not hard-coding anything.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.