Business Roles Custom Report

Hello SailPoint developers,

I am trying to create a custom SailPoint 8.2 report that list all business roles with their IT roles and entitlements grouped under them.

I have looked at all role reports from the OOTB setup but none list the IT roles or entitlements within those roles.

Is this feasible?

Hello Derrick,

If you have option to write a custom rule, you can use the below filter segment to get all the business roles

QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq("type", "business")); 
iterator = context.search(Bundle.class, qo); 

Once you have the iterator you can navigate and get the displayName or other properties you need on the business role. Similar way you can pull all the IT roles as well once you change the type to “it” On this IT role bundle if you get the profiles you can retrieve the entitlements that are mapped within these roles.

Do let me know if you have any queries or need more insights.

1 Like

Hi Rohit,

Unfortunately, I have never wrote a rule before so I may need some more elaborate insight on this.

Hi Derrick,
No worries, Maybe this sample code will help… its a very rough code to create a file on your IIQ installed machine (your server) then add data to that file and send that file as an email…

You can first try out the code by uncommenting the return statement added to return content to ensure the code works… and then can be changed as needed.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule created="" id="" language="beanshell" modified="" name="Custom Report to get Business roles">
  <Source>

  import org.apache.log4j.Logger;  
  import sailpoint.object.QueryOptions;
  import sailpoint.object.Bundle;  
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.OutputStreamWriter;
  import java.io.Writer;  
  import java.util.Iterator;
  import sailpoint.object.EmailOptions;
  import sailpoint.object.EmailFileAttachment;
  import sailpoint.object.EmailTemplate;
  import java.nio.file.Files;
  import java.nio.file.Paths;
  import java.nio.file.Path;
  import sailpoint.tools.Message;

  File file = new File("give your desired path/businessrole.txt"); // create a file where this data will be stored.
  // add file properties like header etc.
  if (!file.exists()) {
    file.createNewFile();
  }

  FileWriter fw = new FileWriter(file.getAbsoluteFile());
  BufferedWriter bw = new BufferedWriter(fw);
  String header= "Role displayName";
  bw.write(header);
  bw.write("\n");

  /*----------- Fetching bundles-----------*/
  QueryOptions qo = new QueryOptions();
  qo.addFilter(Filter.eq("type", "business"));  

  iterator = context.search(Bundle.class, qo);

  while (iterator.hasNext()) {

    Bundle bd= iterator.next();
    if(bd!=null)
    {
      //pick up bundle property
      String content=bd.getDisplayName();
//return content; //uncomment this for testing if needed
      bw.write(content);
      bw.write("\n");
    }
  }

  bw.close();

  String abPath=file.getAbsolutePath();
  Path path = Paths.get(abPath);
  byte[] dataByte = Files.readAllBytes(path);

  String email ="replace with your email address"; // email address for the receiepent needs to go here
  
  Map args = new HashMap(); 	  
  String fileName=file.getName();

  // ...create the attachment..
  EmailFileAttachment attachment = new EmailFileAttachment(fileName, EmailFileAttachment.MimeType.MIME_CSV, dataByte);


  // ...create the email options..
  EmailOptions options = new EmailOptions();


  // ...fill options here...
  options.addAttachment(attachment);
  options.setTo(email);
  
  // ...select the template - replace "enter your email tempalte Name" with your template name....
  EmailTemplate template = context.getObject(EmailTemplate.class, "enter your email tempalte Name");
 
  if(template!=null){
    context.sendEmailNotification(template, options);
    dataByte = null;
    context.decache();
    
    return "Success";

  }
  
  </Source>
</Rule>

1 Like

Rohit,

Is there an easier way to make a custom report and put it into the Reports within SailPoint IIQ? See screenshot below:

Maybe we can get together so i may be able to show you?

Hi Derrick

same is very much possible from reports as well. you will have to create a custom task definition for this. you can try the below code and give it a go

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE TaskDefinition PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<TaskDefinition created="" executor="sailpoint.reporting.LiveReportExecutor" id="" modified="" name="Get users for a role" progressMode="Percentage" resultAction="Rename" subType="Identity and User Reports" template="true" type="LiveReport">
  <Attributes>
    <Map>
      <entry key="report">
        <value>
          <LiveReport title="UserReport">
            <DataSource objectType="sailpoint.object.Bundle" type="Filter">
              <QueryParameters>
                <Parameter>
                  <QueryScript>
                    <Source>

                      import sailpoint.object.*;
                      import org.apache.log4j.Logger;

                    //  Logger myLogger = Logger.getLogger("<<<>>>>>"); // replace with your logger for debugging
                      queryOptions.addFilter(Filter.eq("type", "business"));
                      //myLogger.info(":::::::::::::::: :::: "+queryOptions.toString());
                      return queryOptions;

                    </Source>
                  </QueryScript>
                </Parameter>
              </QueryParameters>
            </DataSource>
            <Columns>
              <ReportColumnConfig field="displayName" header="displayName" property="name" width="110">
                <RenderScript>
                  <Source>

                    import sailpoint.object.*;
                    import sailpoint.api.*;
                    import sailpoint.object.Filter;
                    import sailpoint.object.Bundle;
                    import java.util.List;
                    import sailpoint.api.SailPointContext;

                    import org.apache.log4j.Logger;
                    import sailpoint.tools.GeneralException;
                   //  Logger myLogger = Logger.getLogger("<<<>>>>>"); // replace with your logger for debugging

                    Bundle bd = context.getObjectByName(Bundle.class, value );


                    return bd.getDisplayName();

                  </Source>
                </RenderScript>
              </ReportColumnConfig>
            </Columns>
          </LiveReport>
        </value>
      </entry>
    </Map>
  </Attributes>
  <Description>All business roles</Description>
  <Signature>
    <Inputs>
      <Argument name="resultScope" type="Scope">
        <Description>rept_input_result_scope</Description>
      </Argument>
      <Argument multi="true" name="emailIdentities" type="Identity">
        <Description>rept_input_email_recips</Description>
      </Argument>
    </Inputs>
  </Signature>
</TaskDefinition>

same can be done for IT role by changing the filter