[midPoint] Inbound Attribute Modification

Slavek Licehammer slavek.licehammer at evolveum.com
Thu Apr 2 00:50:03 CEST 2020


Hello Bill.

Groovy is using the last statement as a return value. But in your code, there is no last statement if the input doesn't start with "A".

You can use either of following options:

Option 1:
<code>
  if (input.startsWith("A")) {
    return input.substring(1)
  } 
  return input
</code>

Option 2:
<code>
  if (input.startsWith("A")) {
    input.substring(1)
  } else { 
    input
  }
</code>


Best regards, 

   Slavek Licehammer



On 01/04/2020 23:56, Bill Mills wrote:
> Hello,
> 
> I am working on a CSV connector where the LOGIN attribute is similar to $focus/employeeNumber but it has a leading character in front of the employee numbers. For example "A00000001" or "N00000002". I want to remove the leading character if it is an "A" so I would end up with the following: "00000001" and "N00000002". I'm trying to do this so midPoint can correlate the users in the CSV connector file (e.g. LOGIN) with the HR provided employeeNumber.
> 
> I'm trying to create a groovy script to do this and came up with:
> 
>         <schemaHandling>
>             <objectType id="6">
>                 <kind>account</kind>
>                 <intent>default</intent>
>                 <default>true</default>
>                 <objectClass>ri:AccountObjectClass</objectClass>
>                 <attribute id="7">
>                     <c:ref>ri:LOGIN</c:ref>
>                     <displayName>Login</displayName>
>                     <tolerant>true</tolerant>
>                     <exclusiveStrong>false</exclusiveStrong>
>                     <inbound id="12">
>                         <authoritative>false</authoritative>
>                         <exclusive>false</exclusive>
>                         <strength>weak</strength>
>                         <expression>
>                             <script xsi:type="c:ScriptExpressionEvaluatorType">
>                                 <code>
>                                 if (input.startsWith("A")) {
>                                 input.substring(1)
>                                 }
>                                 </code>
>                             </script>
>                         </expression>
>                         <target>
>                             <c:path>$focus/employeeNumber</c:path>
>                         </target>
>                     </inbound>
>                 </attribute>
> 
> As you can see, I have the code in <schemaHanding> and I've tried it in the <correlation> section but neither working for me. Can you assist me by correcting my <code> or tell me where I should place it in the connector configuration?
> 
> Thanks in advance,
> 
> Bill Mills
> Keysight Technologies
> 
> 
> 
> 
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint
> 



More information about the midPoint mailing list