Mapping Form Input without Contract

1
0
-1

Hello All,

I created a form where not all of the information is not always mandatory for the form. When I map the form with a contract behind it the form doesn't submit, but if I take items out of the contract they don't get mapped when I do enter values. Any help is welcome! Thanks in advance!

Saludos!

1 answer

1
+1
-1
This one is the BEST answer!

Hi,

As you find out all contract inputs are mandatory. But the trick is that null value is accepted!

For example, if a contract define two text input: input1 and input2, following content is valid:
return {
'input1': "test",
'input2': null
};

whereas the following one is not (you get an error 500 with answer: [Expected input [input2] is missing]):
return {
'input1': "test"
};

So you can set your form variables default value to be null and in your process, when you use contract input, first test if they are not null.

Hope this helps

Comments

Submitted by lefloresg on Sat, 01/23/2016 - 00:19

Thank you for your reply!

In the input I have:
{
'input1' : {
attribute 1 [],
attribute 2[],
},
'input2' : {
attribute 1 [],
attribute 2[],
}
};

I have initialized the arrays simply putting: attribute1[0],
in those there are other variables.

I will try to initialize each specific variable with null or 0 and see if it works! Thanks. I'll let you know next week. If it works I'll check best answer!

Submitted by lefloresg on Mon, 02/01/2016 - 18:07

Antoine,

I hope you are well. I've tested the method you suggested but it is not working the way I would have liked.

I was initializing form input the following way:

 {
 "mainInput1" : {
    "iteratedInput1" : [null]
  },
  "mainInput2" : {
    "iteratedInput2" : [null]
  }
}

I then attempted to initialize things like you suggested:

 {
 "mainInput1" : {
    "iteratedInput1" : {
          "attribute1":null,
          "attribute2":null,
          "attribute3":null
    }
  },
  "mainInput2" : {
    "iteratedInput2" : [null]
  }
}

The problem is when I create the form, I get 4 iterations pre-loaded rather than just one I can use an "Add" Button if I need more.

Thanks for your help!

Submitted by antoine.mottier on Fri, 02/05/2016 - 16:06

Hi,

Can you share your process .bos file so I can better understand your use case?

Thanks

Submitted by lefloresg on Fri, 02/05/2016 - 22:34

Antoine,

Here is the file. I recognized its not process related but rather the json definition. Example BOS file The first tab is initialized in the way I would like to see on the form. The second tab is what happens when I try to initiallize each of the variables. I see that the number of lines is dependent on the number of attributes defined in formInput. So if I want to initiallize them with null I would be creating additional instances in the form.

Let me know if you need anything else.

Submitted by antoine.mottier on Wed, 02/10/2016 - 13:50

Hi,

I update your example to initialize the widgets values using the form variable. The same variable is also used to store information about user input and selection.

Hope it's helping. If not, I think a business use case description might help to understand what you are trying to achieve.

Submitted by lefloresg on Wed, 02/10/2016 - 18:20

Antoine, thank you very much, your solution worked!

Submitted by antoine.mottier on Thu, 02/11/2016 - 10:24

Good news! If you are happy with the product can ask you to share your feedback on IT Central Station?

Submitted by lefloresg on Fri, 02/12/2016 - 23:35

Antoine, when I initialize

attribute:null,

and send the data it creates new instances with values of null in all the initialized objects. I don't want to fill my BDO's with records fill with null. Am I doing this right? Thanks

Submitted by antoine.mottier on Thu, 02/18/2016 - 15:56

I will try first to sum up my understanding of your development:

  • You have a form that behave as you expect.
  • The form also let you create a JSON variable that includes all content you want to send to the process in order to store them in a new business data entry.
  • The data received by the process match the contract definition.

Your issue is now that the business variable new entry does not contains what you expect. More precisely it contains an entry matching a null value for a data attribute.

Can you confirm my understanding is correct?

If yes I think I will need from you a bos file with form, process and business data model definitions in order to help you.

Submitted by lefloresg on Mon, 02/22/2016 - 22:24

Antoine,
Thanks for your help. You are correct in your understanding. Here is the BOS

Let me know if you need anything else.

Luis

Submitted by antoine.mottier on Mon, 03/07/2016 - 14:18

In order to help I think I will need a step by step scenario to reproduce your issue.

I need to understand the sequence of actions and value you inputs in various fields.

Thanks

Notifications