Você está na página 1de 6

2 Environments  Workflow Environment & Form Environment

WORKFLOW
You can…
- Flowdata
- Java (List, .size(), .get(),…)
- IDVault methods (no field as parameter)
- RoleVault methods (no field as parameter)
You can’t…
- Form methods
- Field methods

FORM
You can…
- Form methods
- Field methods
- IDVault methods (field as parameter)
- RoleVault methods (field as parameter)
You can’t…
- Flowdata
- Java ((List, .size(), .get(),…)

FLOWDATA
Data mapping:
flowdata.get(“folder”)  return value for non-multivalued fields
flowdata.getObject(“folder”)  return values for multivalued fields
Scripts:
flowdata.get(“folder”).length  return the amount of values [not always working
properly]
flowdata.get( “folder[” + i + ”]” )  return the value in position i (no 0 --- i : 1length)

Loop to get each value in a multivalued flowdata:


var empty = false;
var l = 1;
while (!empty){
if(flowdata.get('folderMulti['+l+']')!="" &&
flowdata.get('folderMulti['+l+']')!=null &&
flowdata.get('folderMulti['+l+']')!='undefined'){
//[DO SOMETHING]
l++;
} else {
empty = true;
}
}
ROLE LEVELS
- Permission Role (Level 10): for ROL_...
- IT Role (Level 20): for APP_... and for BPO/BPM/QA_... (Workflow Approvers)
- Business Role (Level 30)

Fields
- field (pickList) Editable=false  flowdata assignation is not working properly (Revokes:
better to make it Editable=true and put a field.disable() in onload) [it only matters on
the property value, it doesn’t matter if you disable or enable the field many times]
 if show2lists & editable = false, just 1 list shown
- field (pickList) when show2lists  use field.select() not form.select(‘fieldName’)
1st) on the onChange of the “parent” field (if layout/values changes
depending on its value)  all values on the left box
function setRequirementsForRole(oField, oForm, oIDVault) {
if (oField.getValue().indexOf("_COORD") != -1) {
oForm.setRequired("country",true);
oForm.show("country");
oIDVault.globalQuery("country", "ListaRolRole" ,
{"aplication":"_GPM_CTRY_"});
} else {
oForm.setRequired("country",false);
oForm.hide("country");
oForm.setValues("country","");
}
}

2nd) on the onLoad of the field  selected values on the right box
function selectCountries(oField, oForm, oRoleVault){
if (oForm.getValue('role').indexOf('_COORD')>=-1){
countries = oField.getAllValues();
var j = 0;
var selectedCountries = [];
for (var i = 0; i<countries[0].length; i++){
if(oRoleVault.isUserInRole(countries[0]
[i],oForm.getValue('recipient'))){
selectedCountries[j] = countries[0][i];
j++;
}
}
oField.select(selectedCountries);
}
}

Depending on environment
Not environment selector (unique environment or no environment):
- globalquery on DataMapping of PickLists
- SelectRolesInUser in onload event field (to select current values in Modification and
Revoke)
function selectRolesInUser(oForm,oField,oRoleVault){
var roles = oField.getAllValues();
var rolesToAdd=[];
var j = 0;
for (var i=0;i<roles[0].length;i++){
if(oRoleVault.isUserInRole(roles[0][i],
oForm.getValue('recipient'))){
rolesToAdd[j]=roles[0][i];
j++;
}
}
oField.select(rolesToAdd);
}

Environment selector:
- checkEnvironmentAccess() on onchange of environment
function checkEnvironmentAccess(oForm, oField, oRoleVault, oIDVault){
if(oField.getValue()=="prod"){
if(!
oRoleVault.isUserInRole('CN=APP_TRC_PROD,CN=Level20,CN=Role
Defs,CN=RoleConfig,CN=AppConfig,CN=UserApplication,CN=drive
rset1,O=system',oForm.getValue('recipient'))){
$('#SubmitAction1').attr("disabled", true);
oForm.alert("Application isn't already accesed in
PRODUCTION environment");
} else {
$('#SubmitAction1').attr("disabled", false);
oIDVault.globalQuery("roles", "ListaRolRole" ,
{"aplication":sWFAppName+'_PROD_ROLE_'});
oIDVault.globalQuery("rights", "ListaRolRole" ,
{"aplication":sWFAppName+'_PROD_RIGHT_'});
selectRolesInUserFromEnvironment(oForm,oRoleVault);
selectRightsInUserFromEnvironment(oForm,oRoleVault);
}
} else if (oField.getValue()=="test"){
if(!
oRoleVault.isUserInRole('CN=APP_TRC_TEST,CN=Level20,CN=Role
Defs,CN=RoleConfig,CN=AppConfig,CN=UserApplication,CN=drive
rset1,O=system',oForm.getValue('recipient'))){
$('#SubmitAction1').attr("disabled", true);
oForm.alert("Application isn't already accesed in
TEST environment");
} else {
$('#SubmitAction1').attr("disabled", false);
oIDVault.globalQuery("roles", "ListaRolRole" ,
{"aplication":sWFAppName+'_TEST_ROLE_'});
oIDVault.globalQuery("rights", "ListaRolRole" ,
{"aplication":sWFAppName+'_TEST_RIGHT_'});
selectRolesInUserFromEnvironment(oForm,oRoleVault);
selectRightsInUserFromEnvironment(oForm,oRoleVault);
}
}
}

- selector methods inside checkEnvironmentAccess() in modification and revoke (one


different for each field)
function selectRolesInUserFromEnvironment(oForm,oRoleVault){
var roles = oForm.getAllValues("roles");
var rolesToAdd=[];
var j = 0;
for (var i=0;i<roles[0].length;i++){
if(oRoleVault.isUserInRole(roles[0][i],
oForm.getValue('recipient'))){
rolesToAdd[j]=roles[0][i];
j++;
}
}
oForm.select("roles",rolesToAdd);
}

IDVault
IDVault.get(flowdata.get(‘role’), ‘Roles’, ‘nrfLocalizedDescrs’)  to get the description of a role

Debugging
- Using project checker
- oForm.showMsg(“{0} – {1} – {2}”,[role, j, allroles[0][i]]);
IMPORT ROLES FROM CSV
First to Designer and then deploy
COMMON ERRORS
Problem:

Solution:
You have accessed a flowdata value which is not already created

Problem:

Solution:
I didn’t put a timedout flow on the flowdata.

Problem:

Solution:

Você também pode gostar