Wednesday, June 11, 2008

How to print a query name on a report in Axapta

The sysQueryForm form is used to create multiple queries for a report. This form is used by most reports in Microsoft Axapta.

The sysQueryForm form contains a name field. The contents of this name field are printed on the report. However, there is no direct relation between the contents of this name field and the query name.

You can customize Microsoft Axapta to print the query name on the report. To do this, follow these steps:
1. Modify a method to capture the value of the name field. This value holds the query name.
2. Create a method to perform the following tasks:
• Obtain the value of the name field.
• Print this value on the report.


The following code applies to the QueryLoad method. This example code indicates how to modify a method to perform the following tasks:
• Capture the query name.
• Set this variable to a global variable.
switch (_name)
{
case sysQueryForm.queryLastUsedLabel():
saveBtn.enabled(false);
deleteBtn.enabled(true);
break;
case sysQueryForm.queryActiveLabel():
saveBtn.enabled(false);
deleteBtn.enabled(false);
break;
default:
saveBtn.enabled(true);
deleteBtn.enabled(true);

// Add the following two lines to display the query name value.
globalCache = classfactory.globalCache();
globalCache.set("Query","ReportQuery",_name);

break;
}

The following code applies to the Display method. This example code indicates how to create a method to perform the following tasks:
• Obtain the value of the name field.
• Print this value on the report.
Display custAccount Queryname()
{
SysGlobalCache globalCache;
Name queryName;
;

globalCache = classfactory.globalCache();
queryName = globalCache.get("Query","ReportQuery",null);

return queryName;
}

No comments: