How to use global variable GFCYDEF in a query to be used in a landing page?

2 minute read time.

You may or may not be familiar with global variable GFCYDEF, this global variable is an array and it is filled with the default site that is assigned to each Function profile. 

For example if you open Setup, Users , Function Profiles and select your function profile and enter default sites for your profile similar to below screen shot:

Now when you login with a user who is assigned to the above function profile , GFCYDEF(5) will be as an example the default Site for Sales module. 

So what if you add this global variable to a query/requester and add that requester to a landing page, let see what happens when you do that. 

In this example I am taking the standard VEN031 graphical requester and I am adding an additional selection criteria to only select Sales orders that [F:SOH]SALFCY=GFCYDEF(5)

  1. Open Setup, Usage, Reports, Graphical query tool. 
  2. Select VEN031 and click on Advanced tab and enter [F:SOH]SALFCY=GFCYDEF(5) as an additional criteria. 



  3. Click Save and Validate. 
  4. If you run the query you will notice that it works and displays only the sales orders that Sales site matches with the logged user function profile default site. 
  5. But if you go to landing pages and click on Sales Administrator standard landing page you will notice an error like below. 



  6. The reason for the above error is that global variables can't be used in a landing page, since landing pages are part of Syracuse/Web server.

So what is the solution:

Before I get to the solution review online help and search for "API context methods" and you will see below page which describes a context method for getting the default site. 


So the solution consists of creating a function that uses the above context to get the default site and use this function in query/landing page.

  1. Open Development, Script dictionary, Scripts, Script editor.
  2. Create a new script and enter below code. 



    Funprog DEFSITE(MODULE)
    Value Integer MODULE

    Local Char MYSITE(10)
    Local Integer RETVAL

    RETVAL=FMET GACTX.AGETPRFFCYDEF(GACTX,MODULE,MYSITE)

    # Return
    End MYSITE


  3. Click Save and Compile. 
  4. Open Setup, Usage, Reports, Graphical query tool. 
  5. Select VEN031 and click on Advanced tab and enter [F:SOH]SALFCY=func ZSITE.DEFSITE(5) as an additional selection criteria. 



  6. Save and Validate. 
  7. If you run the query manually you will notice that it will work and produces the same result as before and also landing page does not generate any error.

Conclusion: You can use AGETPRFFCYDEF method in context to get the default site.