ManagedAttribute result

Hi All,

We are trying to get the entitlement description using the search method but it is giving an empty iterator and we have also tried with context.getObjects but it is giving an empty list. If we hardcode the values ​​it gives an description but it does not give an description through the process.

Requiremnt is getting the description of th entitlement , can you help me on it

1st

public String description(String appName, String entitlmentName, String attribute) throws GeneralException {
QueryOptions qo = new QueryOptions();
qo.add(Filter.and(Filter.eq(“application.name”, appName), Filter.eq(“attribute”, attribute), Filter.or(Filter.eq(“displayName”, entitlmentName), Filter.eq(“value”, entitlmentName))));

Iterator iter = context.search(ManagedAttribute.class, qo);
while (null != iter && iter.hasNext()) {
ManagedAttribute manageAttr = (ManagedAttribute) iter.next();
  if (null != manageAttr && null != manageAttr.getDescription("en_US")) {
    log.trace("Exiting getDescription (trace=" + (String) manageAttr.getDescription("en_US") + ")");
    return (String) manageAttr.getDescription("en_US");

  }
}
}

2nd
---

public String description(String appName, String entitlementName, String attribute) throws GeneralException {
log.error("Entered getEntRoleDesc");

Application app = context.getObjectByName(Application.class, appName);
if (app == null) {
  log.error("Application not found: " + appName);
  return "N/A";
}

log.debug("Searching for entitlement: " + entitlementName + ", attribute: " + attribute + ", app: " + appName);

// Build the query
QueryOptions qo = new QueryOptions();
qo.add(Filter.and(
  Filter.eq("application", app),
  Filter.eq("value", entitlementName),
  Filter.eq("type", "group")
)  );

// Fetch the first matching ManagedAttribute directly
List ManagedAttribute ma =  context.getObjects(ManagedAttribute.class, qo);
log.error("maaaaaaaa"+ma.toString());
if (ma != null @and !ma.isEmpty()) {
  ManagedAttribute  ma1=ma.get(0);
  if(ma1 != null){
    String desc = ma1.getDescription("en_US");
  }

Hi @sureshbomm,
Can you pull up one of the managed attributes in the debug page, then share the XML with us? Also, let us know of the search parameters you are using that should select the managed attribute.

Hi @sureshbomm , This requirement can also be achieved with the following approach using a simple BeanShell script. It directly retrieves the sysDescriptions["en_US"] value for a specific entitlement. You can also validate the attribute key used for description (like sysDescriptions) in Debug → ManagedAttribute → Attributes to confirm where exactly it’s mapped.

import java.util.List;

String description = "No description";

// Get list of all ManagedAttribute objects
List attrs = context.getObjects(ManagedAttribute.class);

for (int i = 0; i < attrs.size(); i++) {
  ManagedAttribute ma = (ManagedAttribute) attrs.get(i);

  if (ma.getType() != null &&
      ma.getType().equalsIgnoreCase("group") &&
      ma.getApplication().getName().equals("LDAP") &&
      ma.getDisplayName().equals("dir-admin_net")) {

      Object sysDesc = ma.getAttribute("sysDescriptions");
      if (sysDesc instanceof Map) {
          Object enDesc = ((Map) sysDesc).get("en_US");
          if (enDesc != null) {
              description = enDesc.toString();
          }
      }
  }
}

context.commitTransaction();
return description;

Could you try running this rule and let me know if it helps!

Hi @sureshbomm ,

You can use the “ManagedAttributer” class to fetch the description . below is the method which can be used -

ManagedAttribute managedAttribute = ManagedAttributer.get(context,applicationObj,null,entitlementVal);

And call the respective methods according to your requirement .

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.