SharedParamLink: IMetabaseObjectParamLink;
The SharedParamLink property returns settings of parameter link with a global variable.
If link properties are set for a parameter, the value from the global variable is set for the parameter on its initialization. Parameter value can be changed in the future.
If a mode with the ability to change value is set for the parameter, after the parameter is changed, the new value will be sent to a global variable. The changed value of the global variable is stored in cache within the current session and will be reset after work with the repository is finished.
When working with data entry forms, take into account the following feature: parameters described by the IDefParameter interface do not support direct setup of a link with global variables. It is required to determine additional settings:
For a data entry form as a repository object described by the IMetabaseObject interface create parameters and set up a link with global variables.
Determine the same parameters and settings of link with global variables for a report connected with a data entry form.
Executing the example requires that the repository settings should have a custom global variable with the GLOBAL_INT identifier. The repository should also contain an object with the REPORT identifier, for which the ITEM is created. A global variable and an object parameter have the same data type.
Add links to the Metabase system assembly.
Sub UserProc;
Var
Mb: IMetabase;
MObj: IMetabaseObject;
Param: IMetabaseObjectParam;
ParamLink: IMetabaseObjectParamLink;
ParamValues: IMetabaseObjectParamValues;
ParamValue: IMetabaseObjectParamValue;
Begin
Mb := MetabaseClass.Active;
MObj := Mb.ItemById("REPORT").Edit;
// Get parameter settings
Param := MObj.Params.FindById("ITEM");
// Set up link with global variable
ParamLink := Param.SharedParamLink;
ParamLink.ParamId := "GLOBAL_INT";
ParamLink.ReadWriteMode := MetabaseObjectParamReadWriteMode.ReadWrite;
// Save object
MObj.Save;
// Create parameter values
ParamValues := MObj.Params.CreateEmptyValues;
ParamValue := ParamValues.FindById("ITEM");
Debug.WriteLine("Default parameter value: " + ParamValue.Value);
Debug.WriteLine("Global variable value before parameter change: " + Mb.Cache.SharedValue("GLOBAL_INT") As String);
// Change parameter
ParamValue.Value := 1000;
Debug.WriteLine("Global variable value after parameter change: " + Mb.Cache.SharedValue("GLOBAL_INT") As String);
End Sub UserProc;
After executing the example a link is set up between a global variable and an object parameter. Parameter values are initialized, and the development environment console displays parameter value and global variable value. After this the parameter value is changed, and the development environment console displays the updated global variable value.
See also: