cancel
Showing results for 
Search instead for 
Did you mean: 

create a dynamic attribute for each user

Former Member
0 Kudos

Hi All,

I request you all to let me know how to give an approach to the following requirement.

REQUIREMENT: I have to create a dynamic attribute in UME for each user and the read the attribute on lead selection of a table having list of Users.

On lead selection, the dynamic attribute value should be either true or false. Based on this value the rest of the application specific operations wil be taken care.

If a particular User does not have the dynamic attribute associated to it, then we need to create the same.

Looking forwarrd for your help.

Regards

Dipendra

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member192152
Active Participant
0 Kudos

Hi Dipendra,

your problem is solved?

regards,

Angelo

Former Member
0 Kudos

Hi,

Refer this for creating dynamic attribute to the user.

Here 'Flag' is the attribute used here.

//To get the values of the custom attribute ..

IWDClientUser LoggedUser = WDClientUser.getCurrentUser(); //Here try to get your user in the table.

IUserMaint User = UMFactory.getUserFactory().getMutableUser(LoggedUser.getSAPUser().getUniqueID());

String Value[]=User.getAttribute("com.sap.security.core.usermanagement","Flag");

if (Value==null||Value.length==0)

{

//Means no attribute so create the attribute..

User.addAttributeValue("com.sap.security.core.usermanagement","Flag","TRUE or FALSE");

}

else

{

//Sample code for getting the value of theattribute

for (int i=0;i<Value.length;i++)

{

wdComponentAPI.getMessageManager().reportSuccess("Value of the custom Att"+Value);

}

}

When the user exits the application Just remove that attribute..

User.removeAttributeValue("com.sap.security.core.usermanagement","Flag","FALSE");

User.commit();

Note: Dont add the same attribute in same namespace with same value twice for the same user..

Just put a check before adding the attribute

Best Wishes

former_member192152
Active Participant
0 Kudos

//@@begin javadoc:UMSavePropertiesByNode()
	/** Declared method. */
  //@@end
  public boolean UMSavePropertiesByNode( )
  {
    //@@begin UMSavePropertiesByNode()
		try {
			if (wdContext.currentUserDataElement().getVaIUserMaint().setAttribute("com.sap.security.core.usermanagement", this.getUMPropertyName(null) + ".TableColumns", this.getPropertiesByNode())) {
				wdContext.currentUserDataElement().getVaIUserMaint().save();
				wdContext.currentUserDataElement().getVaIUserMaint().commit();
				msg.reportMessage(IMessageTableUtilsComponent.UMPROPERTY__SAVE__FIELDS__SUCCESS, null, false);
			}
		} catch (UMException ex) {
			wdContext.currentUserDataElement().getVaIUserMaint().rollback();
			msg.reportMessage(IMessageTableUtilsComponent.UMPROPERTY__SAVE__FIELDS__ERROR, null, false);
			return false;
		}

		return true;
    //@@end
  }

  //@@begin javadoc:UMLoadFieldsProperties()
	/** Declared method. */
  //@@end
  public petrobras.com.br.classes.FieldsTable UMLoadFieldsProperties( petrobras.com.br.classes.FieldsTable fields )
  {
    //@@begin UMLoadFieldsProperties()

		String properties[] = wdContext.currentUserDataElement().getVaIUserMaint().getAttribute("com.sap.security.core.usermanagement", this.getUMPropertyName(null) + ".TableColumns");

		if (Compare.getLenght(properties) > 0) {
			//msg.reportWarning("[UMLoadFieldsProperties]: properties.length = " + properties.length);
			for (int i = 0; i < properties.length; i++) {

				int attrPos = Integer.parseInt(properties<i>.substring(properties<i>.indexOf("(") + 1, properties<i>.indexOf(")")));
				String attrName = (String) properties<i>.substring(properties<i>.indexOf(")") + 1, properties<i>.indexOf("="));
				int attrValue = Integer.parseInt(properties<i>.substring(properties<i>.indexOf("=") + 1, properties<i>.indexOf(";")));

				Field item = fields.getField(attrName);

				if (item != null) {
					item.setPosition(attrPos);
					item.setVisibility(WDVisibility.valueOf(attrValue));
					
					fields.removeFieldByName(attrName);
					fields.addField(item);
				}
			}
		} 

		return fields;
    //@@end
  }

regards,

Angelo