Before Provisioning Rule for ServiceDesk Integration

Hi, I need to customize the ticket fields based on the requirements and need Before Provisioning Rule for the same.

Can anyone help me with the steps on how to have additional attributes in service desk and also a sample before provisioning rule for it.

Thankyou

Hi Anshuk! PFB the sample code. That may help you.

import sailpoint.object.Identity; 
import sailpoint.object.IntegrationConfig; 
import org.apache.commons.logging.Log; 
import org.apache.commons.logging.LogFactory; 
import sailpoint.tools.GeneralException; 
import sailpoint.object.ProvisioningPlan.AccountRequest; 	
import sailpoint.object.*; 
import sailpoint.api.*; 
import sailpoint.object.ProvisioningPlan.AccountRequest; 
import sailpoint.object.ProvisioningPlan.AccountRequest.Operation; 
import sailpoint.object.ProvisioningPlan.AttributeRequest; 
import sailpoint.object.ProvisioningPlan; 
import sailpoint.object.Attributes; 
import sailpoint.object.ProvisioningPlan.Operation; 

Log log = LogFactory.getLog(\"openconnector.connector.servicedesk.ServiceDeskConnector\"); 
if (plan == void || plan == null) {
 log.error(\"Before Provisioning Rule SDIM - Plan is null.\"); 
 throw new GeneralException(\"Before Provisioning Rule SDIM - Plan is null.\"); 
} 
List requesterList = plan.getRequesters(); 
Identity requester = null; 
if (requesterList != null && requesterList.size() > 0) {
 requester = requesterList.get(0); 
} 
String appName = integration.getName(); 
String requesterSource = null; 
String identityFirstname = null; 
String identityLastname = null; 
String identityLoginId = null; 
String sourceAppName = null; 
String accountRequest= null; 
String sourceDisplayName = null; 
if (appName != null) { 
 requesterSource = (String)idn.getSourceAttributeBySourceName(appName, \"requesterSource\");
} 
// Get Account's native Identity (aka unique accountId) 
String openedBy = null; 
String requestedFor = null; 
if (requesterSource != null) {
 if (requester != null) {
  openedBy = idn.getFirstAccountNativeIdentity(requesterSource, requester.getName());
 } 
  if (identity != null) {
   requestedFor = idn.getFirstAccountNativeIdentity(requesterSource, identity.getName());
  }
} 
else {
 log.warn(\"Attribute 'requesterSource' is null in the application: \" + appName);
} 	
Attributes attrs = new Attributes();
String upn = ""; 	
String saMAccountName = ""; 
if (identity != null) {
 identityFirstname = identity.getFirstname(); 
 identityLastname = identity.getLastname(); 
 if(requesterSource != null && requestedFor != null) {
  identityLoginId = idn.getAccountAttribute(requesterSource,requestedFor, \"LoginName\");
 } 		
attrs.put("firstName", identityFirstname); 		
attrs.put("lastName", identityLastname); 		
attrs.put("email", plan.getIdentity().getEmail()); 		
attrs.put("department", plan.getIdentity().getAttribute("department")); 		
attrs.put("title", plan.getIdentity().getAttribute("title")); 		
attrs.put("manager", plan.getIdentity().getManager().getName()); 
} 
if (identityFirstname != null) { 
 plan.put(\"identityFirstname\", identityFirstname); 
} 
if (identityLastname != null) {
 plan.put(\"identityLastname\", identityLastname); 
} 
if (identityLoginId != null) {
 plan.put(\"loginId\", identityLoginId);
} 
if (requestedFor != null) { 
 plan.put(\"requested_for\", requestedFor); 
} 
if (openedBy != null) { 
 plan.put(\"opened_by\", openedBy); 
} 
if (identity.getName() != null) { 
 plan.put(\"identityName\", identity.getName()); 
} 	
List links=    identity.getLinks();
Iterator iterator = links.iterator();
while(iterator.hasNext()) {
	Link link = (Link)iterator.next();
	String applicationName = link.getApplicationName();
	Application source = link.getApplication();
	if(applicationName.toLowerCase().contains("Active Directory")) {
			upn = idn.getAccountAttribute(applicationName, link.getNativeIdentity(), "userPrincipalName");
			saMAccountName = idn.getAccountAttribute(applicationName, link.getNativeIdentity(), "sAMAccountName"); //
	break;
	}
}
attrs.put("upn", upn); 	
attrs.put("saMAccountName", saMAccountName); 
List accounts = plan.getAccountRequests(); 
if(accounts != null && accounts.size() > 0) { 
 for(AccountRequest accountRequest : accounts) { 
  sourceAppName = accountRequest.getApplicationName(); 
  sourceDisplayName = (String) idn.getSourceAttributeBySourceName(sourceAppName, \"cloudDisplayName\"); 
  accountRequest.put(\"sourceDisplayName\", sourceDisplayName); 			
  String ump=""; 			
	if(accountRequest.getApplication().getName().contains("UMP")){
	AttributeRequest attribReq = accountRequest.getAttributeRequest("groups");
	if(attribReq!=null) {
			String attributeName = attribReq.getName();
			String attributeValue = attribReq.getValue();
			String appID = accountRequest.getApplication().getId();
			ManagedAttributeDetails entDetails = idn.getManagedAttributeDetails(appID, attributeName, attributeValue, Type.group);
			ump = entDetails.getAttributes().get("provisioningAuthority");
		}
	}
	attrs.put("ump", ump);			 
} 
} 	
 plan.setArguments(attrs);
1 Like

Hi Deepak,

I am curious to part of the code to get the SourceID, as far as i can tell getApplication is just a string.

String appID = accountRequest.getApplication().getId();