Your integration may have an additional resource type for which you want to control security access. This new security resource type will appear just like any of the built-in security resource types such as windows or reports. Creating a new security resource type requires several steps. The remainder of this section describes how to add a new security resource type (named New Security Type), with two series (Series 1 and Series 2), and the corresponding security operations. The Security Task Setup window with the new security resource type is shown in the following illustration.
The security resource type must be added to the list of types in the Security Task Setup window. Do this by creating a procedure trigger for the AddOtherSecurityType procedure of the sySecurityTaskEntry form. The following example shows the registration for this trigger.
l_result = Trigger_RegisterProcedure(script AddOtherSecurityType of form sySecurityTaskEntry, TRIGGER_AFTER_ORIGINAL, script IG_Security_AddType); if l_result <> SY_NOERR then warning "Procedure trigger registration to create security type failed."; end if;
The following is the trigger processing procedure that adds a new security resource type to the list of types in the Security Task Setup window. Notice how the ID for the security resource type is saved as the data value for the list item.
When specifying the value for the security item type, be sure to use values other than those defined by the core Dynamics GP product. Values below 100 are reserved for Dynamics GP. |
in integer dict_ID; if isopen(window syTaskEntry of form sySecurityTaskEntry) then if dict_ID = IG_PROD_ID then {New security resource type with value 1} add item "New Security Type", 100 to '(L) SecurityType' of window syTaskEntry of form sySecurityTaskEntry; end if; end if;
After the user has chosen the new security resource type, the Series drop-down list in the Security Task Setup window must be populated with values appropriate to the new type. This is done by creating a procedure trigger for the LoadSecuritySeriesDDL procedure of the sySecurityTaskEntry form. The following example shows the registration for this trigger.
l_result = Trigger_RegisterProcedure(script LoadSecuritySeriesDDL of form sySecurityTaskEntry, TRIGGER_AFTER_ORIGINAL, script IG_Security_AddSeriesItems); if l_result <> SY_NOERR then warning "Trigger registration to add series for security type failed."; end if;
The following is the trigger processing procedure that adds the series items for the new security resource type. Notice how the ID for each series is saved as the data value for the list item.
in integer dict_ID; in long security_type; if isopen(window syTaskEntry of form sySecurityTaskEntry) then if dict_ID = IG_PROD_ID then {It's our product, so add the security series items} if security_type = 100 then {Add the items} add item "Series 1", 1 to field '(L) SecuritySeries' of window syTaskEntry of form sySecurityTaskEntry; add item "Series 2", 2 to field '(L) SecuritySeries' of window syTaskEntry of form sySecurityTaskEntry; {Set the security resource type use by the core Dynamics GP code} Restype of window syTaskEntry of form sySecurityTaskEntry = 100; end if; end if; end if;
After the user has selected the type and series for the new security resource type, the Access List must be filled with the items of that type. This is done by creating a procedure trigger for the Load3rdPartyOperationsIntoLV procedure of the sySecurityTaskEntry form. The following example shows the registration for this trigger.
l_result = Trigger_RegisterProcedure(script Load3rdPartyOperationsIntoLV of form sySecurityTaskEntry, TRIGGER_AFTER_ORIGINAL, script IG_Security_LoadItemsForType); if l_result <> SY_NOERR then warning "Trigger registration to add items for security type failed."; end if;
The following is the trigger processing procedure that adds the items for the new security resource type that are in the selected series. It must set up the database infrastructure for the Security Task Entry window. For each item, the procedure does the following:
in integer dict_ID; in integer security_type; in integer security_series; local sySecurityTaskOperationsState TaskOperationsState; local long status; if isopen(window syTaskEntry of form sySecurityTaskEntry) then if dict_ID = IG_PROD_ID then if security_type = 100 then status = Create(TaskOperationsState, table sySecurityAssignTaskOperations) of form sySecurityTaskOperations; if status <> OKAY then abort script; end if; if security_series = 1 then {Look up the security status of each item as it is added, so that the marked or unmarked state can be set} {Series 1 Item 1 -- ID is 101} call SetIndex of form sySecurityTaskOperations, TaskOperationsState, 'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry, IG_PROD_ID, 101, security_type; status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations; if status = OKAY then {User already has access} call LoadListView of form sySecurityTaskEntry, "Item 101", 101, security_type, dict_ID, true; else {User does not have access} call LoadListView of form sySecurityTaskEntry, "Item 101", 101, security_type, dict_ID, false; end if; {Series 1 Item 2 -- ID is 102} call SetIndex of form sySecurityTaskOperations, TaskOperationsState, 'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry, IG_PROD_ID, 102, security_type; status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations; if status = OKAY then {User already has access} call LoadListView of form sySecurityTaskEntry, "Item 102", 102, security_type, dict_ID, true; else {User does not have access} call LoadListView of form sySecurityTaskEntry, "Item 102", 102, security_type, dict_ID, false; end if; end if; if security_series = 2 then {Series 2 Item 1 -- ID is 201} call SetIndex of form sySecurityTaskOperations, TaskOperationsState, 'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry, IG_PROD_ID, 201, security_type; status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations; if status = OKAY then {User already has access} call LoadListView of form sySecurityTaskEntry, "Item 201", 201, security_type, dict_ID, true; else {User does not have access} call LoadListView of form sySecurityTaskEntry, "Item 201", 201, security_type, dict_ID, false; end if; {Series 2 Item 2 -- ID is 202} call SetIndex of form sySecurityTaskOperations, TaskOperationsState, 'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry, IG_PROD_ID, 202, security_type; status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations; if status = OKAY then {User already has access} call LoadListView of form sySecurityTaskEntry, "Item 202", 202, security_type, dict_ID, true; else {User does not have access} call LoadListView of form sySecurityTaskEntry, "Item 202", 202, security_type, dict_ID, false; end if; end if; call ClearRange of form sySecurityTaskOperations, TaskOperationsState; call Destroy of form sySecurityTaskOperations, TaskOperationsState; end if; end if; end if;
Reports in Microsoft Dynamics GP provide information about the tasks assigned to users. When you add a new security type, you must also register three additional triggers that allow reports to retrieve the security resource type, series, and name of the operations you are defining for that type.
To retrieve the security type name, register a procedure trigger for the GetResourceTypeforTaskSetupReport() global function. The following example shows the registration for the function trigger that retrieves the type for a security task.
l_result = Trigger_RegisterFunction(function GetResourceTypeforTaskSetupReport, TRIGGER_AFTER_ORIGINAL, function IG_Security_GetType); if l_result <> SY_NOERR then warning "Function trigger registration for retrieving task type failed."; end if;
The following is the trigger processing procedure that retrieves the name for a security resource type.
function returns string sType; in 'Security Resource Type' security_type; in integer dict_ID; in 'Security ID' security_ID; if dict_ID = IG_PROD_ID then if security_type = 100 then sType = "New Security Type"; end if; end if;
To retrieve the series name for a security task, register a procedure trigger for the GetResourceSeriesforTaskSetupReport() global function. The following example shows the registration for the function trigger that retrieves the series for a task.
l_result = Trigger_RegisterFunction(function GetResourceSeriesforTaskSetupReport, TRIGGER_AFTER_ORIGINAL, function IG_Security_GetSeries); if l_result <> SY_NOERR then warning "Trigger registration for retrieving task series failed."; end if;
The following is the trigger processing procedure that retrieves the series name for a security task.
function returns string sSeries; in 'Security Resource Type' security_type; in integer dict_ID; in 'Security ID' security_ID; out integer series_value; if dict_ID = IG_PROD_ID then if security_type = 100 then case security_ID in[101] sSeries = "Series 1"; in[102] sSeries = "Series 1"; in[201] sSeries = "Series 2"; in[202] sSeries = "Series 2"; end case; end if; end if;
To retrieve the name for an operation, register a procedure trigger for the GetResourceNameforTaskSetupReport() global function. The following example shows the registration for the function trigger that retrieves the name for a security operation.
l_result = Trigger_RegisterFunction(function GetResourceNameforTaskSetupReport, TRIGGER_AFTER_ORIGINAL, function IG_Security_GetOperationName); if l_result <> SY_NOERR then warning "Trigger registration for retrieving operation name failed."; end if;
The following is the trigger processing procedure that retrieves the name for a security operation.
function returns string sName; in 'Security Resource Type' security_type; in integer dict_ID; in 'Security ID' security_ID; if dict_ID = IG_PROD_ID then if security_type = 100 then case security_ID in[101] sName = "Item 101"; in[102] sName = "Item 102"; in[201] sName = "Item 201"; in[202] sName = "Item 202"; end case; end if; end if;