How to pass attribute from WorkFlow?

Which IIQ version are you inquiring about?

8.3

Share all details about your problem, including any error messages you may have received.

I am creating a workflow to receive email create request from ServiceNow and create email in SailPoint.
This is the initial step where reading the requestion coming from ServiceNow

		String strParameters=returnBlank(Parameters);                				
		ArrayList paramList = JsonUtil.parse(strParameters); 
               								
		for (Map paramMap : paramList) 
		{
			
			if("UserId".equalsIgnoreCase(paramName))
			{
				  workflow.put("userId", paramValue);
			}
		}
		           								   				   			   		  		
	   		
		String requesteeID=returnBlank(workflow.get("userId"));
	   			   
		if(requesteeID.equalsIgnoreCase(""))
		{
			strErrorMessage.append("UserId Missing in request").append("  ,  ");
		}else
		{
			  Identity identityRequestee = getIdentity(context, "staffId", requesteeID);
	   
			  
	   
			  if(identityRequestee==null)
			  {
					strErrorMessage.append("User Id not available in Identity Warehouse").append("  ,  ");
			  }else
			  {
				   
				   workflow.put("identityName", identityRequestee.getName());
				   workflow.put("identityDisplayName", identityRequestee.getDisplayName());
				   //context.decache(identityRequestee);
			  }
	         }

I want to pass above “userId” into “identity”

  String output = "";   
     
      Identity identity = context.getObjectByName(Identity.class,identityName);
             
      if(identity == null)
      {
          // Return Empty
      }  
	  
      if(null!=identity)
        {String accountName = identity.getStringAttribute("staffId");
           String compCode   =  identity.getStringAttribute("compCode");}

@j1241 if you are doing put in same workflow then you need in another steps.

  • Hoping you define Variable on top
  • you can set value in by workflow.put(“userId”, “ABC”);
  • In next step, you can simply pass as argument and directly get the value or you can use workflow.get(“userId”);

If you are calling subworkflow, then while calling another WF, you can pass as argument and in next workflow you need to declare and mark input=true while defining the variable.

Can you give some more insight ?

Thank you @pravin_ranjan for your reply

It is happening in one workflow but different step

Here is the complete workflow i created

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Workflow PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Workflow  explicitTransitions="true" id="" modified="" name="  Email Provisioning" type="IdentityLifecycle">
  
  <Step name="Initialize and Validate" posX="146" posY="127">
    <Script>
      <Source>
                				
		String strParameters=returnBlank(Parameters);
               
		log.debug("strParameters: "+strParameters);			
		ArrayList paramList = JsonUtil.parse(strParameters); 
               
		log.debug("paramList: "+paramList);
						
		StringBuffer strErrorMessage=new StringBuffer();
				
		for (Map paramMap : paramList) 
		{
			log.debug("The paramMap: "+paramMap);
			String paramName=returnBlank(paramMap.get("Name"));
			String paramValue=returnBlank(paramMap.get("Value"));
				
			log.debug("The paramName: "+paramName);
			log.debug("The paramValue: "+paramValue);
				
			if("ChangeRequest".equalsIgnoreCase(paramName))
			{
				  workflow.put("changeRequestNo", paramValue);  
			}
			if("RITM_SYSID".equalsIgnoreCase(paramName))
			{
				  workflow.put("ritmSysId", paramValue);
			}
			if("ChangeSource".equalsIgnoreCase(paramName))
			{
				  workflow.put("changeSource", paramValue);
			}
			if("UserId".equalsIgnoreCase(paramName))
			{
				  workflow.put("userId", paramValue);
			}
		}
		           				   				   				 			   		
		String requesteeID=returnBlank(workflow.get("userId"));	  		
	   
		if(requesteeID.equalsIgnoreCase(""))
		{
			strErrorMessage.append("UserId Missing in request").append("  ,  ");
		}else
		{
			  Identity identityRequestee = getIdentity(context, "staffId", requesteeID);
	   
			  log.debug("the identity is"+identityRequestee); 
	   
			  if(identityRequestee==null)
			  {
					strErrorMessage.append("User Id not available ");
			  }else
			  {
				   
				   workflow.put("identityName", identityRequestee.getName());
				   workflow.put("identityDisplayName", identityRequestee.getDisplayName());
				  
			  }
	         }  	           
	</Source>
    </Script>
    <Transition to="Provision Email - Create"/>
  </Step>
  <Step icon="Task" name="Provision Email - Create" posX="278" posY="129" resultVariable="errorStr">
    <Script>
      <Source>
      	            
      String output = "";   
     
      Identity identity = context.getObjectByName(Identity.class,identityName);
             
      if(identity == null)
      {
          
      }
        
      Map psAttributes = new HashMap();
	    boolean useTLS = true;
	    String emailAddress = "";
        
     
	  
      if(null!=identity)
        {
                                
          String accountName = identity.getStringAttribute("staffId");
           String compCode   =  identity.getStringAttribute("compCode");
                                      
                psAttributes.put("accountName",accountName);
                psAttributes.put("companyCode",compCode);
                                       
                HashMap dataMap = new HashMap();
                String appName = "Active Directory";
                Application app = context.getObject(Application.class, appName);
        
            }
        
                
        if(emailAddress != null &amp;&amp; !emailAddress.isEmpty())
         workflow.put("confirmMsg",emailAddress);
        else
         workflow.put("confirmMsg",""+identity.getAttribute("email")+" existed already for this identity - "+identity.getName());

      return output;                               
			                 
      </Source>
    </Script>
    <Transition to="Update ServiceNow"/>
  </Step> 
  <Step icon="Stop" name="Stop" posX="614" posY="130"/>
</Workflow>

this is what I thought

Identity identity = workflow.get(“userId”);
inplace of
Identity identity = context.getObjectByName(Identity.class,identityName);

@j1241 Try

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Workflow PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Workflow  explicitTransitions="true" id="" modified="" name="  Email Provisioning" type="IdentityLifecycle">
  <Variable name="userId"/>
  <Step name="Initialize and Validate" posX="146" posY="127">
    <Script>
      <Source>
                				
		String strParameters=returnBlank(Parameters);
               
		log.debug("strParameters: "+strParameters);			
		ArrayList paramList = JsonUtil.parse(strParameters); 
               
		log.debug("paramList: "+paramList);
						
		StringBuffer strErrorMessage=new StringBuffer();
				
		for (Map paramMap : paramList) 
		{
			log.debug("The paramMap: "+paramMap);
			String paramName=returnBlank(paramMap.get("Name"));
			String paramValue=returnBlank(paramMap.get("Value"));
				
			log.debug("The paramName: "+paramName);
			log.debug("The paramValue: "+paramValue);
				
			if("ChangeRequest".equalsIgnoreCase(paramName))
			{
				  workflow.put("changeRequestNo", paramValue);  
			}
			if("RITM_SYSID".equalsIgnoreCase(paramName))
			{
				  workflow.put("ritmSysId", paramValue);
			}
			if("ChangeSource".equalsIgnoreCase(paramName))
			{
				  workflow.put("changeSource", paramValue);
			}
			if("UserId".equalsIgnoreCase(paramName))
			{
			   workflow.put("userId", paramValue);
			}
		}
		           				   				   				 			   		
		String requesteeID=returnBlank(workflow.get("userId"));	  		
	   
		if(requesteeID.equalsIgnoreCase(""))
		{
			strErrorMessage.append("UserId Missing in request").append("  ,  ");
		}else
		{
			  Identity identityRequestee = getIdentity(context, "staffId", requesteeID);
	   
			  log.debug("the identity is"+identityRequestee); 
	   
			  if(identityRequestee==null)
			  {
					strErrorMessage.append("User Id not available ");
			  }else
			  {
				   
				   workflow.put("identityName", identityRequestee.getName());
				   workflow.put("identityDisplayName", identityRequestee.getDisplayName());
				  
			  }
	         }  	           
	</Source>
    </Script>
    <Transition to="Provision Email - Create"/>
  </Step>
  <Step icon="Task" name="Provision Email - Create" posX="278" posY="129" resultVariable="errorStr">
    <Arg name="userId" value="ref:userId/>
    <Script>
      <Source>
      	            
      String output = "";   
     
      Identity identity = context.getObjectByName(Identity.class,userId);
             
      if(identity == null)
      {
          
      }
        
      Map psAttributes = new HashMap();
	    boolean useTLS = true;
	    String emailAddress = "";
        
     
	  
      if(null!=identity)
        {
                                
          String accountName = identity.getStringAttribute("staffId");
           String compCode   =  identity.getStringAttribute("compCode");
                                      
                psAttributes.put("accountName",accountName);
                psAttributes.put("companyCode",compCode);
                                       
                HashMap dataMap = new HashMap();
                String appName = "Active Directory";
                Application app = context.getObject(Application.class, appName);
        
            }
        
                
        if(emailAddress != null &amp;&amp; !emailAddress.isEmpty())
         workflow.put("confirmMsg",emailAddress);
        else
         workflow.put("confirmMsg",""+identity.getAttribute("email")+" existed already for this identity - "+identity.getName());

      return output;                               
			                 
      </Source>
    </Script>
    <Transition to="Update ServiceNow"/>
  </Step> 
  <Step icon="Stop" name="Stop" posX="614" posY="130"/>
</Workflow>

1 Like

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