cancel
Showing results for 
Search instead for 
Did you mean: 

Script for setting up ProfileValue for user

Former Member
0 Kudos

Hi SDK gurus,

Environment: Windows 2012 Server, SAP BI 4.1 SP05

Scenario:

We have to assign profile value to group of employees.

Group will be based on employee job code (Fetching Job Code & Employee Number field from Windows AD into CMS)

After adding employees into group, we have to assign their employee number as profile value.

Now this activity should be repeated everyday, as there may be chances of job code change daily.

I have created one group. And looking for below process in code.

1. Remove profile values (only Employee number, as there may be more profile value assigned to user) of all employee belongs to the group

2. Remove all users from the group

3. Add users in the group based on their job code

4. Assign Employee Number as profile value to user.

I already developed code for first 3 points. But stuck at 4rth.

I am not able to change Value Type of profile. It should be 2 (Type = Value), but by default it is taking 1, Full Client filter (Type = Filter)

Challenge: Below script is assigning value to user/profile, but whenever we are trying to publish a report, we are getting error. And that is obvious, because we are not setting Profile Value Type "Value" and by default it is taking as FullClient "Filter".

BusinessObjects_PublicationAdminErrorLog_Instance_749712 - [Publication ID # 749712] - Unable to find a profile filter expression for the document type "Webi" for the user or group '27,131' (ID: 748,171) and profile '{3}' (ID: {4}). Please ensure that your administrator has set a filter expression for document type "Webi" in the profile in the Central Management Console. (FBE60317)



Below is the part of code.


Set aset;

String s1;

String s2;

int empno;

int SAPempno;

String s3;

IInfoObjects boInfoObjects_addProfile;

boInfoObjects_addProfile = (IInfoObjects)infoStore.query("SELECT * FROM CI_SYSTEMOBJECTS WHERE DESCENDANTS(\"SI_NAME = 'USERGROUP-USER'\" , \"SI_NAME= 'Account Managers'\")");

for(int boCount_addProfile  =0; boCount_addProfile  < boInfoObjects_addProfile.size(); boCount_addProfile++ )

{

  IInfoObject boObject = (IInfoObject)boInfoObjects_addProfile.get(boCount_addProfile);

  IUserBase bouserbase = (IUserBase)boObject;

  IUser bouser = (IUser)bouserbase;

  imapattrib = bouser.getCustomMappedAttributes();

  aset = imapattrib.getAttributeNames();

  s1 = imapattrib.getAttribute("SI_EMPLOYEENUMBER");

  empno = Integer.parseInt(s1);

  SAPempno = 10000000 + empno;

  s3 = Integer.toString(SAPempno);

  s2 = imapattrib.getAttribute("SI_JOBCODE");

        // Retrieve the user as an ISystemPrincipal object.

        ISystemPrincipal userPrincipal = (ISystemPrincipal)boInfoObjects_addProfile.get(boCount_addProfile);

        // Create the association between principal and profile.

        IProfileValues profileValues = userPrincipal.getProfileValues();

        IProfileValue profileValueObject = profileValues.add(profileID);

  IProfileValueItems vitems = profileValueObject.getValues();

  IProfileValueItem vitem = vitems.add();

        // Set the profile value.

        vitem.setValueItemValue(s3);

  out.println("Adding profile values for: " +boObject.getTitle()+ ": " + boObject.getDescription()+ ": SI_EMPLOYEENUMBER: " +s1+": Job Code: " +s2+": New employee number: " +s3+"</br>"  );

infoStore.commit(boInfoObjects_addProfile);

}



Any inputs will be highly appreciated.


Thanks,

Sameer

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Guys

We can do the same by using below function.

setTargetType()

Thanks,

Sameer

Answers (0)