Admiral
Admiral
1196 views

How to migrate an old Form to FormBuilder in IDM 4.8.2.1

Dear all,

now one year has passed and I was thinking of starting to get my hendy dirty with the new Form Builder introduced with IDM 4.8.

The first form, providing only some filed wich could be read and moved to flowdata was not such a big deal, but the next one is really driving me creasy.

I want to setup a form providing a dn lookup and some fields. After selecting a user with the dn lookup, I want some attributes from the selected user read from the IDVault and out the fields of that form.

In the legacy form thgis was not a big deal: I simply configured the onchange event of the dnLookup field to run some idvault.get() and filed.set commands and I was done.

But I can not find really the spot where to do this in the new form bulider, and I am guessing a new functions have to  be used as well.

 

Can anybody provide some hint, please?

 

BTW: Am I too blind or is there simply close to no documentation on this new IDM module available? 

 

Kind regards,

 

Thorsten

 

 

 

20 Replies
Admiral
Admiral

Good point, but I had an OSP issue with the new fowms at the beginning, which was solved by assigning NGnix the same key/certificate asigend to tomcat.

During the installation NGnix - which is providing the forms service - is configured with a self-signed certificate, which is not related to the one Tomcat is using nor to the local CA! This is really a bug in the installation!

But after fixing this accessing forms in general is possible. I can even pass data into and from the form to flowdata. The (only) thing not working is accessing DAL data from within the form (form- & field-scripts)

 

Kind regards,

Thorsten

Commodore
Commodore

The workflow.war must have the truststore on the command line it is otherwise picking your default jre/lib/security/cacerts as trust store which is probably you don't want.

Look for the -D parameter to set

Michiel Los
Admiral
Admiral

The Tomcat instance running workflow.war (and most other IDMApplications) is using its own keystore and truststore, as set by the installation. So the key and own certificate are in tomcat.ks and all other certifictes in idm.jks.

 

Since all IDM Apps are working - including workflows with legacy forms I am pretty sure I do not have any certificate issues at this end. Even a workflow using a legacy form can access the DAL as expected.

New forms on the other hand are provided by a new service provided by NGnix running on the same host. This Webserver by default is using its own self-signed certificate, which makes it impossible for some browsers to even access it. But I fixed this issue by assigning this Webserver the same SSLconfiguration as Tomcat.

An other issue I was facing was, that the new forms service configuration did not get the OSPclientPassword. But after adding the password to the config.ini of this service all related OSP errors were gone.

Since I can access the new forms and pass data in and out I do not think I am facing any certificate issues anymore - The only thing not working (so far) is accessing DAL data from within a running form.

Kind regards,

 

Thorsten

 

 

Admiral
Admiral

Finally I found something, but there is still something missing 😞

I sat up the following form:

Bildschirmfoto 2020-12-17 um 08.36.23.png

The form is providing one dnLookup, a text field and two data fields - one for telephone and one for mobile.

The text field is set to the dn of the user selected by the dnlookup component, and is for testing only.

Meanwhile I found, the JSEditor is providing the IDVault functions and it provides complete functions to be used.

Bildschirmfoto 2020-12-17 um 08.37.13.png

 

It would be great, to have this capability - or at least a hint to it - in the WYSIWG editor, this would have saved me a lot of time searching for the correct syntax!

Looking at the code I ended up with

 

function telephone_CalculateValue () {if (data.SelectUserDN  !==''){
IDVault.get('IDM','/rest/access/entities/list','cn=jd0815,ou=active,ou=user,ou=data,o=maintainet','idmuser','TelephoneNumber')
    .then(function (data){
    	return instance.setFieldValue();  //Pass the data that you want to set in the field as a parameter to this function. 
})
.catch(function (error){ return error;});
}
else{
  value = 'nothing selected';
}}Using this code I don't see the [objcet permise] I received before, but simply nothing at all in the telephone filed.

 

Using this code, I do not get the [object permise] as a value in the thelephone filed, but simply nothing at all.

Any ideas?

 

 

 

 

Admiral
Admiral

Got it - up to some point 😉

in the last code the instance.setFieldValue() did not provide any value, but if data.TelephoneNumber is used as a parameter, the value will be set to the field!

function telephone_CalculateValue () {if(data.SelectUserDN !==''){
  //value ='DN selected: ' +  data.SelectUserDN;
  var userdn = data.SelectUserDN;
  IDVault.get('IDM','/rest/access/entities/list',userdn, 'idmuser', 'TelephoneNumber')
  .then(function (data){
  	return instance.setFieldValue(data.TelephoneNumber);  //Pass the data that you want to set in the field as a parameter to this function. 
})
.catch(function (error){ return error;})
}
else{
  value = 'No User selected';
}}

So far so good! But for some reason this code is executed only once! After selecting another user, the field value is not changed!

This is confusing, since the debug code I used on the mobile field refreshes the value on every chnage of the dnlookup.

function telephone_CalculateValue () {if(data.SelectUserDN !==''){
  value ='DN selected: ' + data.SelectUserDN;
}
else{
  value = 'No User selected';
}}

If you compare the two functions, I replaced imply the code in the then-part.

I am guessing the problem is resulting from the usage of the  data object. after the IDVault.get the data is containing the resolut from the query I guess and therefore the change of the dnlookup is not recgognized anymore.

 have to confess I am not really understanding which objects to use here to access the field values in the right way!

Any ideas?

 

Kind regards,

 

Thorsten

Admiral
Admiral

Just one "strange" update:

As I wrote before, the mobile field value is updated on any change of the dnlookup and it is showing the selected DN!

The telephone is only updated once, but if I change the dn, and manually delete the value from telephone, the correct value put into the field by the field script!

Is this not strange?!

 

 

 

 

 

0 Likes
Admiral
Admiral

Hi everybody,

since I am still facing the issue, fields with values resulting from an asynchronous IDMVault.get function call are only updated once I am wondering if some here can help me with the following questions.

I Understand, the new way to implement the IDVault.get offers the chance, to query for moire than one attribute at a time.

 

IDVault.get('IDM','/rest/access/entities/list',userdn, 'idmuser', ['personalMobile','homePhone'])

In this case the returned object - lets call it result- will provide both values by using either result.personalMobile or result.homePhone.

As a consequence it would be great to "store" the result object some where in the form (i.e. a hidden field) and init the "real" data fields accessing the properties of this object.

I have to confess, I do not have any clue on the promise object calls used here and how to handle them, but maybe someone here could help me with this (general) question 😉

I am guessing tghis would be a great option, since only one DAL query would be used for the whole form and not one query/field!

 

Kind regards,

 

Throsten

 

0 Likes
Admiral
Admiral

Finally - with some help - I found some answers:

In my last post I described a JavaScript for the Calculated Value of a field using a promise function call to set the field value:

IDVault.get('IDM','/rest/access/entities/list', data.SelectUserDN, 'idmuser',['homePhone'])
.then((response) => {instance.setFieldValue(response.homePhone)})
.catch((error) => {instance.setFieldValue('No Data')});
//.finally((response) => {instance.setFieldValue(response.homePhone)});
}

Using this code, the fields were only updated once! But  with a little more configuration the update was working as expected:

Within the Data configuration of this field the option "Clear Value on Refresh" has to be selected. After this change the field value was updated on any change of the dnlookup field.

In this case any field providing a dynamic value needs a script and this script will trigger an REST call against the IDM DAL.

To limit the REST calls just to one, you could introduce a hidden field, which will get the response object of an REST call as a value and after  that fired a custom event.

The great thing with the REST API is, that in this particular case it is able to provide more than one attribute in the DAL query:

IDVault.get('IDM','/rest/access/entities/list', data.SelectUserDN, 'idmuser',['attribute1','attribute2','attributeN])

in this case the previous code needs one more instruction:

IDVault.get('IDM', '/rest/access/entities/list', data.selectUser, 'user', ['TelephoneNumber','LastName','FirstName','CN','Email'])
.then(function (response) {
instance.setValue(response);
//form.getComponent('lastName').setValue(response.LastName);
instance.emit("userUpdated");
})
.catch(function (error) { return error; })
}
 
In this case the "dynamic" fields will not need any script in the Calculated Value, and the option "Clear on Refresh" does not have to be selected. Instead, a Logic has to be introduced, which will be triggered by the event (i.e. "userUpdated") to set the value by an JavaScript like:
 
value = data.saveUserDetails['FirstName'][0]
 
In this case "saveUserDetails" is the API name of the hidden field providing the response object.
 
I am still struggling on using a function to setFieldValues directly, meaning having anything in one code element, but there seems to be an issue with this approach.
 
Kind regards,
 
Thorsten

 

Admiral
Admiral

Thank you for sharing this information.

How nice it would be if MF would have written some decent documentation about it.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.