on 06-19-2015 1:53 PM
Please paste in as code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
// Main function: hei_getIdentityDateEmailReady
function hei_getIdentityDateEmailReady(Par){
//mskey of the mx_person entry type would be passed as the parameter
var script = "hei_getIdentityDateEmailReady::";
logLevel = uGetConstant("glb.HEI_LOG_LEVEL");
selectDelimiter = "!!"; // used for delimiting the two column values returned by query
queryDelimeter = "|"; // user for delimiting the bulk records;
// the below query returns the results in the format Attribute and mcValue, for attributes which are empty it returns Null values
Var query = "with CTe as (" +
"select 'MX_FS_SALUTATION_ID' as Attribute,1 as SNO union " +
"select 'MX_LASTNAME' as Attribute,2 as SNO union " +
"select 'MX_FIRSTNAME' as Attribute,3 as SNO union " +
"select 'MX_NICKNAME' as Attribute,4 as SNO union " +
"select 'MX_INITIALS' as Attribute,5 as SNO union " +
"select 'DISPLAYNAME' as Attribute,6 as SNO union " +
"select 'HEI_IDEN_USER_ACCOUNT_ID' as Attribute,7 as SNO union " +
"select 'MSKEYVALUE' as Attribute,8 as SNO union " +
"select 'MX_FS_EMPLOYEE_GROUP_ID' as Attribute,9 as SNO union " +
"select 'HEI_IDEN_INITIAL_HIRING_DATE' as Attribute,10 as SNO union " +
"select 'HEI_IDEN_LEAVING_DATE' as Attribute,11 as SNO union " +
"select 'MX_FS_EMPLOYMENT_STATUS_ID' as Attribute,12 as SNO union " +
"select 'HEI_IDEN_ADDRESS_REGION_CODE' as Attribute,13 as SNO union " +
"select 'MX_FS_PERSONNEL_AREA_ID' as Attribute,14 as SNO union " +
"select 'HEI_IDEN_OPERATING_COMPANY_ID' as Attribute,15 as SNO union " +
"select 'MX_FS_COMPANY_CODE_ID' as Attribute,16 as SNO union " +
"select 'HEI_IDEN_JOB_FUNCTION_ID' as Attribute,17 as SNO union " +
"select 'MX_FS_PERSONNEL_SUBAREA_ID' as Attribute,18 as SNO union " +
"select 'MX_FS_ORGANIZATIONAL_UNIT' as Attribute,19 as SNO union " +
"select 'MX_FS_POSITION' as Attribute,20 as SNO union " +
"select 'MX_MANAGER' as Attribute,21 as SNO union " +
"select 'MX_COSTCENTER' as Attribute,22 as SNO union " +
"select 'MX_FS_PERSONNEL_NUMBER' as Attribute,23 as SNO union " +
"select 'HEI_IDEN_LOCAL_EMPLOYEE_CODE' as Attribute,24 as SNO union " +
"select 'MX_MAIL_PRIMARY' as Attribute,25 as SNO union " +
"select 'HEI_IDEN_LYNC_ADDRESS' as Attribute,26 as SNO union " +
"select 'MX_PHONE_PRIMARY' as Attribute,27 as SNO union " +
"select 'MX_MOBILE_PRIMARY' as Attribute,28 as SNO union " +
"select 'MX_WORKPLACE_BUILDING' as Attribute,29 as SNO union " +
"select 'MX_WORKPLACE_ROOM' as Attribute,30 as SNO union " +
"select 'HEI_IDEN_STATUS_VALUE' as Attribute,31 as SNO union " +
"select 'MX_LANGUAGE' as Attribute,32 as SNO union " +
"select 'MX_USERTYPE' as Attribute,33 as SNO union " +
"select 'MX_ADMIN_UNIT' as Attribute,34 as SNO union " +
"select 'MX_TIMEZONE' as Attribute,35 as SNO " +
")select SNO,Attribute,mcSearchValue from CTe " +
"left outer join (select * from idmv_vallink_basic with (nolock) where MSKEY = " +Par+ " ) A on Attribute = mcAttrName " +
"order by SNO";
if(logLevel >= 2) {
uErrMsg(1, script + "Par: [" + Par + "]; query: [" + query + "]");
}
var retVal = uSelect(query);
var tempArr = retVal.split(queryDelimeter); // To separate each row and save it in the array list
retValue = "";
for (i=0;i<tempArr.length;i++) // this is used for iterating the array
{
tempArr1 = tempArr[i].split(selectDelimiter); // here the columns returned by the above query are delimited using !!
switch (tempArr1[0])
{
CASE : "MX_FS_SALUTATION_ID"
retValue = retValue + "Form-of-Address: " + tempArr1 [i] + "\n";
break;
CASE : "MX_LASTNAME"
retValue = retValue + ""Last name: "" + tempArr1 [i] + "\n";
break;
CASE : "MX_FIRSTNAME"
retValue = retValue + "First name: " + tempArr1 [i] + "\n";
break;
CASE : "MX_NICKNAME"
retValue = retValue + "Known as: " + tempArr1 [i] + "\n";
break;
CASE : "MX_INITIALS"
retValue = retValue + "Initials: " + tempArr1 [i] + "\n";
break;
CASE : "DISPLAYNAME"
retValue = retValue + "Displayname: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_USER_ACCOUNT_ID"
retValue = retValue + "Useraccount ID: " + tempArr1 [i] + "\n";
break;
CASE : "MSKEYVALUE"
retValue = retValue + "Unique ID: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_EMPLOYEE_GROUP_ID"
retValue = retValue + "Employee Group: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_INITIAL_HIRING_DATE"
retValue = retValue + "Initial Hiring Date: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_LEAVING_DATE"
retValue = retValue + "Leaving Date: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_EMPLOYMENT_STATUS_ID"
retValue = retValue + "Employment Status: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_ADDRESS_REGION_CODE"
retValue = retValue + "Region Code: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_PERSONNEL_AREA_ID"
retValue = retValue + "Personnel Area: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_OPERATING_COMPANY_ID"
retValue = retValue + "Business Unit/Operating Company: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_COMPANY_CODE_ID"
retValue = retValue + "Financial Legal Entity: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_JOB_FUNCTION_ID"
retValue = retValue + "Functional Area / Global Function: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_PERSONNEL_SUBAREA_ID"
retValue = retValue + "Personnel Subarea: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_ORGANIZATIONAL_UNIT"
retValue = retValue + "Organizational Unit Text: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_POSITION"
retValue = retValue + "Position Text: " + tempArr1 [i] + "\n";
break;
CASE : "MX_MANAGER"
retValue = retValue + "Manager: " + tempArr1 [i] + "\n";
break;
CASE : "MX_COSTCENTER"
retValue = retValue + "Cost Center: " + tempArr1 [i] + "\n";
break;
CASE : "MX_FS_PERSONNEL_NUMBER"
retValue = retValue + "Personnel Number: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_LOCAL_EMPLOYEE_CODE"
retValue = retValue + "Local Employee Code: " + tempArr1 [i] + "\n";
break;
CASE : "MX_MAIL_PRIMARY"
retValue = retValue + "Primary E-Mail: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_LYNC_ADDRESS"
retValue = retValue + "Lync Address: " + tempArr1 [i] + "\n";
break;
CASE : "MX_PHONE_PRIMARY"
retValue = retValue + "Primary Telephone Number: " + tempArr1 [i] + "\n";
break;
CASE : "MX_MOBILE_PRIMARY"
retValue = retValue + "Primary Mobile Number: " + tempArr1 [i] + "\n";
break;
CASE : "MX_WORKPLACE_BUILDING"
retValue = retValue + "Building Code: " + tempArr1 [i] + "\n";
break;
CASE : "MX_WORKPLACE_ROOM"
retValue = retValue + "Room Number: " + tempArr1 [i] + "\n";
break;
CASE : "HEI_IDEN_STATUS_VALUE"
retValue = retValue + "Identity Status: " + tempArr1 [i] + "\n";
break;
CASE : "MX_LANGUAGE"
retValue = retValue + "Language: " + tempArr1 [i] + "\n";
break;
CASE : "MX_USERTYPE"
retValue = retValue + "User Type: " + tempArr1 [i] + "\n";
break;
CASE : "MX_ADMIN_UNIT"
retValue = retValue + "User Group: " + tempArr1 [i] + "\n";
break;
CASE : "MX_TIMEZONE"
retValue = retValue + "Time Zone: " + tempArr1 [i] + "\n";
break;
}
}
if(logLevel >= 2) {
uErrMsg(1, script + "Par: [" + Par + "]; retvalue: [" + retValue + "]");
}
return retValue;
}
Hi DP,
In line,
Var query = "with CTe as (" +
the 'v' in Var should be small. So it should be
var query = "with CTe as (" +
This should solve ";" missing error. Other than that I can see few scripting errors. Consider reviewing fully once. Thanks.
Kind regards,
Jai
Message was edited by: Jai Suryan
Hello experts,
Received runtime exception while executing the below script. based on the hint when i have looked at the line 27 i couldn't find the '.' in the script. kindly please help me
RuntimeException - org.mozilla.javascript.EvaluatorException: uSelect(select [priv].SNO,[priv].ATTRIBUTE,A.searchvaluefrom dbo.priv_notification_attribute [priv]left join (select MSKEY,AttrName,SearchValue from idmv_value_basic with (nolock) where MSKEY =216) A on priv.ATTRIBUTE = A.attrname) got exception com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '.'. HINT: Check line 27 in the script hei_l_getIdentityDateEmailReady
// Main function: hei_l_getIdentityDateEmailReady
function hei_l_getIdentityDateEmailReady(Par){
//mskey of the mx_person entry type would be passed as the parameter
var script = "hei_getIdentityDateEmailReady::";
logLevel = uGetConstant("glb.HEI_LOG_LEVEL");
selectDelimiter = "!!"; // used for delimiting the two column values returned by query
queryDelimeter = "|"; // user for delimiting the bulk records;
if(logLevel >= 2) {
uErrMsg(1, script + "Par: [" + Par + "]");
}
// the below query returns the results in the format Attribute and mcValue, for attributes which are empty it returns Null values
var query = "select [priv].SNO,[priv].ATTRIBUTE,A.searchvalue" +
"from dbo.priv_notification_attribute [priv]" +
"left join (select MSKEY,AttrName,SearchValue from idmv_value_basic with (nolock) where MSKEY =" + Par + ") A " +
"on priv.ATTRIBUTE = A.attrname"
"Order by [priv].SNO;";
var retVal = uSelect(query);
var tempArr = retVal.split(queryDelimeter); // To separate each row and save it in the array list
retValue = "";
for (i=0;i<tempArr.length;i++) // this is used for iterating the array
{
tempArr1 = tempArr[i].split(selectDelimiter); // here the columns returned by the above query are delimited using !!
switch (tempArr1[0])
{
case 'MX_FS_SALUTATION_ID' :
retValue = retValue + "Form-of-Address: " + tempArr1 [i] + "\n";
break;
case 'MX_LASTNAME' :
retValue = retValue + "Last name: " + tempArr1 [i] + "\n";
break;
}
}
if(logLevel >= 2) {
uErrMsg(1, script + "Par: [" + Par + "]; retvalue: [" + retValue + "]");
}
return retValue;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi DP
I'm not sure what you're actually trying to achieve with this script (or the one above) but it looks like you're making life very hard for yourself. What do you actually need to do?
It looks like you're getting attributes which are dynamic but then ignoring them if they aren't the two specified. You'd find it much better and faster to just retrieve the two attributes directly from the object.
Anyway -
Your priv.ATTRIBUTE is not in [] but every other one is, including the name declaration.
You have spaces between tempAttr1 [i].
You don't need the semi-colon in the query string.
For consistency, you should probably put var in front of selectDelimiter and queryDelimiter although, given that they're only used once you could ditch them and just use literals.
Peter
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.