<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Solved!</p>
    <p>I use the following Groovy code:</p>
    <p><i>if (input == null) {</i><i><br>
      </i><i>  def verCode = UUID.randomUUID().toString()</i><i><br>
      </i><i>  return verCode</i><i><br>
      </i><i>}</i><br>
    </p>
    <p>It generates UUIDs in the form:
      5eaaa9d3-26fe-4e18-9e37-4469999f1b06, perfect!<br>
    </p>
    <p>But I still can't get this generated value to be stored in the
      employeeNumber attribute of the user schema attribute of midPoint,
      it is stored in the database correctly, but the employeeNumber
      attribute is still null in midPoint.</p>
    <p>My inbound and outbound mapping is:<br>
    </p>
    <p>        <i><attribute id="30"></i><i><br>
      </i><i>                <ref>ri:AFI_ID</ref></i><i><br>
      </i><i>                <description>Identificador único,
        generado automáticamente</description></i><i><br>
      </i><i>                <matchingRule
xmlns:gen459=<a class="moz-txt-link-rfc2396E" href="http://prism.evolveum.com/xml/ns/public/matching-rule-3">"http://prism.evolveum.com/xml/ns/public/matching-rule-3"</a>>gen459:default</matchingRule></i><i><br>
      </i><i>                <tolerant>true</tolerant></i><i><br>
      </i><i>               
        <exclusiveStrong>false</exclusiveStrong></i><i><br>
      </i><i>                <b><outbound></b></i><i><br>
      </i><i>                   
        <authoritative>true</authoritative></i><i><br>
      </i><i>                   
        <exclusive>false</exclusive></i><i><br>
      </i><i>                    <strength>normal</strength></i><i><br>
      </i><i>                    <source></i><i><br>
      </i><i>                       
        <path>$focus/employeeNumber</path></i><i><br>
      </i><i>                    </source></i><i><br>
      </i><i>                    <target></i><i><br>
      </i><i>                       
        <path>$projection/attributes/AFI_ID</path></i><i><br>
      </i><i>                    </target></i><i><br>
      </i><i>                </outbound></i><i><br>
      </i><i>                <b><inbound id="49"></b></i><i><br>
      </i><i>                   
        <authoritative>true</authoritative></i><i><br>
      </i><i>                   
        <exclusive>false</exclusive></i><i><br>
      </i><i>                    <strength>normal</strength></i><i><br>
      </i><i>                    <expression></i><i><br>
      </i><i>                        <script></i><i><br>
      </i><i>                           <code></i><i><br>
      </i><i>                                if (input == null) {<br>
                                            def verCode =
        UUID.randomUUID().toString()<br>
                                            return verCode<br>
                                        }<br>
      </i><i>                           </code></i><i><br>
      </i><i>                        </script></i><i><br>
      </i><i>                    </expression></i><i><br>
      </i><i>                    <target></i><i><br>
      </i><i>                       
        <path>$focus/employeeNumber</path></i><i><br>
      </i><i>                    </target></i><i><br>
      </i><i>                </inbound></i><i><br>
      </i><i>            </attribute></i><br>
      <br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">El 17/02/2022 a las 9:21,
      <a class="moz-txt-link-abbreviated" href="mailto:midpoint-request@lists.evolveum.com">midpoint-request@lists.evolveum.com</a> escribió:
    </div>
    <blockquote type="cite"
      cite="mid:mailman.416.1645086078.17334.midpoint@lists.evolveum.com">
      <pre class="moz-quote-pre" wrap="">----------------------------------------------------------------------

Message: 2
Date: Thu, 17 Feb 2022 09:21:11 +0100
From: MERCEDES ONCINA DELTELL <a class="moz-txt-link-rfc2396E" href="mailto:moncina@um.es"><moncina@um.es></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a>
Subject: Re: [midPoint] Error in script condition during inbound
        mapping
Message-ID:
        <a class="moz-txt-link-rfc2396E" href="mailto:20220217092111.Horde.cixgCxTnahig_t8VwNcjHUe@webmail.um.es"><20220217092111.Horde.cixgCxTnahig_t8VwNcjHUe@webmail.um.es></a>
Content-Type: text/plain; charset="utf-8"; Format="flowed";
        DelSp="Yes"

  I have configured the condition with input == null and midPoint  
generates correctly the value and update it into the database table,  
but it is not mapped into the employeeNumber attribute, I do not know  
why, it is null in midPoint while it has a value in the table, also,  
if I reconcile the user, the value in the database table remains  
intact, this behaviour is perfect, but I can not see this value in the  
midPoint user.

On the other hand, I have seen the kind of values that midPoint  
generates with this expression, 8 alphanumeric characters. What I want  
is to generate an UUID, so I am trying to use the "uuidgen" Linux  
command, and I have tried this:
  <script xmlns:org=<a class="moz-txt-link-rfc2396E" href="http://midpoint.evolveum.com/xml/ns/public/common/org-3">"http://midpoint.evolveum.com/xml/ns/public/common/org-3"</a>>
     <code>
        "uuidgen -x -r".execute()
     </code>
  </script>

  But the error I get when I try to import a user is:

Expected class java.lang.String type, but got class  
java.lang.ProcessImpl in expression in mapping in inbound expression  
for AFI_ID in  
resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)(actor=user:00000000-0000-0000-0000-000000000002(administrator); input=null; resource=<a class="moz-txt-link-freetext" href="resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)">resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)</a>; configuration=systemConfiguration:00000000-0000-0000-0000-000000000001(SystemConfiguration); focus (user)=user:null(null); projection (shadow, account)=shadow:e6452b1b-496a-429a-8d07-3452e5b6c1ee(34812812); operation=add; ) in expression in mapping in inbound expression for AFI_ID in  
<a class="moz-txt-link-freetext" href="resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)">resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)</a>

Thanks.


<a class="moz-txt-link-abbreviated" href="mailto:midpoint-request@lists.evolveum.com">midpoint-request@lists.evolveum.com</a> escribió:

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">------------------------------

Message: 2
Date: Wed, 16 Feb 2022 14:15:51 +0100
From: Mercedes Oncina Deltell <a class="moz-txt-link-rfc2396E" href="mailto:moncina@um.es"><moncina@um.es></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a>
Subject: [midPoint] Error in script condition during inbound mapping
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:224b64b9-93b8-28ed-815b-521651eedf23@um.es"><224b64b9-93b8-28ed-815b-521651eedf23@um.es></a>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hello again.

I have learned a lot about midPoint during last week. Now, I have a new
question.

I want to import an attribute which could be null in the database table,
it is mapped into the employeeNumber attribute of the user schema in
midPoint. If it is null in the database, I want to random generate a
value and map it into the attribute, but if it contains a value, I just
only want to import it.

As this employeeNumber should always have a value in midPoint, it is
mapped out to the property AFI_ID in the database table. My objective
is, if in database the value is null, midPoint will generate this value
and then, update it to the database again.

I have tried many configurations and (I think) I know where the problem
is, in the script code of the condition of the inbound mapping:

/<attribute id="30">//
//*<ref>ri:AFI_ID</ref>*//
//                <description>Identificador único, generado
automáticamente</description>//
//                <matchingRule
xmlns:gen459=<a class="moz-txt-link-rfc2396E" href="http://prism.evolveum.com/xml/ns/public/matching-rule-3">"http://prism.evolveum.com/xml/ns/public/matching-rule-3"</a>>gen459:default</matchingRule>//
//                <tolerant>true</tolerant>//
//<exclusiveStrong>false</exclusiveStrong>//
/*/                <outbound>/*/
//<authoritative>true</authoritative>//
//<exclusive>false</exclusive>//
//<strength>normal</strength>//
//*<source>*/*/
/**/<path>$focus/employeeNumber</path>/**/
/**/                    </source>/**/
/**/                </outbound>/*/
//                <inbound id="49">//
//<authoritative>true</authoritative>//
//<exclusive>false</exclusive>//
//<strength>normal</strength>//
//*<expression>*/*/
/**/                        <generate/>/**/
/**/                    </expression>/*/
//                    <target>//
//<path>$focus/employeeNumber</path>//
//                    </target>//
//*<condition>*/*/
/**/                        <script>/**/
/**/                           <code>/**/
/**/$projection/attributes/AFI_ID == null/**/
/**/                           </code>/**/
/**/                        </script>/**/
/**/                    </condition>/*/
//                </inbound>//
//            </attribute>/

But this configuration is not correct, maybe because it is not a Groovy
expression, the error when I try to reconcile or import an user is:

Groovy Evaluation Failed: No such property: $projection for class:
condition_in_mapping_in_inbound_expression_for_AFI_ID_in_resource_3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT(actor=user:00000000-0000-0000-0000-000000000002(administrator);
input=PPV(String:wB7TPNFn);
resource=<a class="moz-txt-link-freetext" href="resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)">resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)</a>;
configuration=systemConfiguration:00000000-0000-0000-0000-000000000001(SystemConfiguration);
focus (user)=user:null(null); projection (shadow,
account)=shadow:4a56dbf2-93ab-4ae5-8b4d-3747f34711fe(34812808);
operation=add; ) in condition in mapping in inbound expression for
AFI_ID in
<a class="moz-txt-link-freetext" href="resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)">resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)</a>

Could anyone advice me about this kind of expressions?

Thanks in advance.

--
Mercedes Oncina Deltell
Servicio de Infraestructuras TICS
ATICA - Universidad de Murcia
Telf: +34 868881983
-------------- next part --------------
An HTML attachment was scrubbed...
URL:  
<a class="moz-txt-link-rfc2396E" href="https://lists.evolveum.com/pipermail/midpoint/attachments/20220216/61772317/attachment-0001.htm"><https://lists.evolveum.com/pipermail/midpoint/attachments/20220216/61772317/attachment-0001.htm></a>

------------------------------

Message: 3
Date: Wed, 16 Feb 2022 17:18:49 +0000
From: Paulo Fernandes de Souza Junior <a class="moz-txt-link-rfc2396E" href="mailto:PFSJ@senado.leg.br"><PFSJ@senado.leg.br></a>
To: midPoint General Discussion <a class="moz-txt-link-rfc2396E" href="mailto:midpoint@lists.evolveum.com"><midpoint@lists.evolveum.com></a>
Cc: Mercedes Oncina Deltell <a class="moz-txt-link-rfc2396E" href="mailto:moncina@um.es"><moncina@um.es></a>
Subject: Re: [midPoint] Error in script condition during inbound
        mapping
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:1645031929533.1242@senado.leg.br"><1645031929533.1242@senado.leg.br></a>
Content-Type: text/plain; charset="iso-8859-1"

Use input == null in the condition.

Paulo Fernandes de Souza Júnior
NQPPPS
Senado Federal - PRODASEN
Fone: 61 3303.3924

________________________________
De: midPoint <a class="moz-txt-link-rfc2396E" href="mailto:midpoint-bounces@lists.evolveum.com"><midpoint-bounces@lists.evolveum.com></a> em nome de  
Mercedes Oncina Deltell via midPoint <a class="moz-txt-link-rfc2396E" href="mailto:midpoint@lists.evolveum.com"><midpoint@lists.evolveum.com></a>
Enviado: quarta-feira, 16 de fevereiro de 2022 10:15
Para: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a>
Cc: Mercedes Oncina Deltell
Assunto: [midPoint] Error in script condition during inbound mapping

Hello again.

I have learned a lot about midPoint during last week. Now, I have a  
new question.

I want to import an attribute which could be null in the database  
table, it is mapped into the employeeNumber attribute of the user  
schema in midPoint. If it is null in the database, I want to random  
generate a value and map it into the attribute, but if it contains a  
value, I just only want to import it.

As this employeeNumber should always have a value in midPoint, it is  
mapped out to the property AFI_ID in the database table. My  
objective is, if in database the value is null, midPoint will  
generate this value and then, update it to the database again.

I have tried many configurations and (I think) I know where the  
problem is, in the script code of the condition of the inbound  
mapping:

           <attribute id="30">
               <ref>ri:AFI_ID</ref>
               <description>Identificador único, generado  
automáticamente</description>
               <matchingRule  
xmlns:gen459=<a class="moz-txt-link-rfc2396E" href="http://prism.evolveum.com/xml/ns/public/matching-rule-3">"http://prism.evolveum.com/xml/ns/public/matching-rule-3"</a><a class="moz-txt-link-rfc2396E" href="http://prism.evolveum.com/xml/ns/public/matching-rule-3"><http://prism.evolveum.com/xml/ns/public/matching-rule-3></a>>gen459:default</matchingRule>
               <tolerant>true</tolerant>
               <exclusiveStrong>false</exclusiveStrong>
               <outbound>
                   <authoritative>true</authoritative>
                   <exclusive>false</exclusive>
                   <strength>normal</strength>
                   <source>
                       <path>$focus/employeeNumber</path>
                   </source>
               </outbound>
               <inbound id="49">
                   <authoritative>true</authoritative>
                   <exclusive>false</exclusive>
                   <strength>normal</strength>
                   <expression>
                       <generate/>
                   </expression>
                   <target>
                       <path>$focus/employeeNumber</path>
                   </target>
                   <condition>
                       <script>
                          <code>
                             $projection/attributes/AFI_ID == null
                          </code>
                       </script>
                   </condition>
               </inbound>
           </attribute>

But this configuration is not correct, maybe because it is not a  
Groovy expression, the error when I try to reconcile or import an  
user is:

Groovy Evaluation Failed: No such property: $projection for class:  
condition_in_mapping_in_inbound_expression_for_AFI_ID_in_resource_3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT(actor=user:00000000-0000-0000-0000-000000000002(administrator); input=PPV(String:wB7TPNFn); resource=<a class="moz-txt-link-freetext" href="resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)">resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)</a>; configuration=systemConfiguration:00000000-0000-0000-0000-000000000001(SystemConfiguration); focus (user)=user:null(null); projection (shadow, account)=shadow:4a56dbf2-93ab-4ae5-8b4d-3747f34711fe(34812808); operation=add; ) in condition in mapping in inbound expression for AFI_ID in  
<a class="moz-txt-link-freetext" href="resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)">resource:3a091f48-850c-4ee8-ae1c-eac5c264c41c(MIDPOINT.AFILIACIONES)</a>

Could anyone advice me about this kind of expressions?

Thanks in advance.

--
Mercedes Oncina Deltell
Servicio de Infraestructuras TICS
ATICA - Universidad de Murcia
Telf: +34 868881983
-------------- next part --------------
An HTML attachment was scrubbed...
URL:  
<a class="moz-txt-link-rfc2396E" href="https://lists.evolveum.com/pipermail/midpoint/attachments/20220216/53f41c2a/attachment.htm"><https://lists.evolveum.com/pipermail/midpoint/attachments/20220216/53f41c2a/attachment.htm></a>

------------------------------

Subject: Digest Footer

_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="https://lists.evolveum.com/mailman/listinfo/midpoint">https://lists.evolveum.com/mailman/listinfo/midpoint</a>

------------------------------

End of midPoint Digest, Vol 118, Issue  
34*****************************************
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">-------------- next part --------------
An HTML attachment was scrubbed...
URL: <a class="moz-txt-link-rfc2396E" href="https://lists.evolveum.com/pipermail/midpoint/attachments/20220217/ce52e5f7/attachment.htm"><https://lists.evolveum.com/pipermail/midpoint/attachments/20220217/ce52e5f7/attachment.htm></a>

------------------------------

Subject: Digest Footer

_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="https://lists.evolveum.com/mailman/listinfo/midpoint">https://lists.evolveum.com/mailman/listinfo/midpoint</a>


------------------------------

End of midPoint Digest, Vol 118, Issue 37
*****************************************
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Mercedes Oncina Deltell
Servicio de Infraestructuras TICS
ATICA - Universidad de Murcia
Telf: +34 868881983</pre>
  </body>
</html>