You are viewing limited content. For full access, please sign in.

Question

Question

Copy Collection Select field value to Single Line Field

asked on December 19, 2019

In the below image, I have a Collection that allows the user to add multiple Stops. Within each stop the user will be required to select a value from the drop-down.

I need to copy the value from Stop 1 "HIB" to a Single Line field on Leg 1. Copy the value from Stop 2 "HBN" to a Single Line field on Leg 2, etc.

 

How can I accomplish this using jquery OR can this be done using a Forms Calculation?

0 0

Answer

SELECTED ANSWER
replied on December 19, 2019 Show version history

Can you double check the form designer to make sure you're not getting an error? (make sure you refresh the page and double check the variable names all match up too)

Also, is it possible that your CSS is hiding an on-page error message?

With that calculation, there's no way it should just have a "blank" result unless there is some kind of error in the calculation or it isn't using the right variable(s).

Side note, don't put the = in front of the variable, it should be as follows:

=IF(COUNTIF(route.rig,"<>")>1,INDEX(route.rig,2),msr_destination)

That extra = sign should have prompted an error message, which is why I recommend refreshing the designer page after you set the calculation.

1 0

Replies

replied on December 19, 2019 Show version history

For the first collection item you can use a simple calculation to retrieve the first index value.

=INDEX(Collection.Drop_down,1)

For the second one, you might want a more complex calculation. If the user can remove rows and there is a chance the collection might only have one item, you need to verify there is more than one row.

For example,

If you tried INDEX(Collection.Drop_down,2) but there is only one row in the collection, you will get an error message on the form.

So, you can use a COUNTIF function first to check if there are actually 2 rows, then put the index function inside of that.

=IF(COUNTIF(Collection.Drop_down,"<>")>1,INDEX(Collection.Drop_down,2),"")

This calculation checks if there is more than 1 blank field in the collection. If there is, it copies the value of the second item, if not, it leaves the field blank.

Just be sure to replace the "Collection.Drop_down" part with your actual variables from the > menu.

3 0
replied on December 19, 2019 Show version history

Thanks Jason

 

My apologies, I didn't include this in the original post. If there is only one row, in this case, HBN, I need a Single Line field on Leg 2 to have the value of the Destination dropdown shown below.

 

0 0
replied on December 19, 2019

In that case you would probably just need to change the IF condition.

For example,

=IF(COUNTIF(Collection.Drop_down,"<>")>1,INDEX(Collection.Drop_down,2),Destination)

What this is doing is the following:

If Collection count > 1 use 2nd value from Collection

Else, use Destination value

1 0
replied on December 19, 2019

The calculation will not accept the variable (msr_destination) for the Destination  field.

0 0
replied on December 19, 2019 Show version history

What do you mean? Can you post the calculation you're trying to use? There's no reason it would not accept the variable unless it was misspelled, or possibly if you were trying to put it inside an index function.

0 0
replied on December 19, 2019

I've tried:

 

=IF(COUNTIF(route.rig,"<>")>1,INDEX(route.rig,2),=msr_destination)

and

=IF(COUNTIF(route.rig,"<>")>1,INDEX(route.rig,2),msr_destination)

0 0
replied on December 19, 2019

Okay, and what exactly is going wrong when you use the second calculation? Is it just not populating the value, or is it returning an error (either in the designer when you refresh, or on the form itself when you select the values)?

0 0
replied on December 19, 2019

Using =IF(COUNTIF(route.rig,"<>")>1,INDEX(route.rig,2),=msr_destination) it's just not populating.

 

0 0
replied on December 19, 2019

Wait, are you trying to populate a field, or something like a header or custom HTML?

Calculations only work with fields, so if you're trying to populate something else you would need to do that with JavaScript.

In the original post you mentioned this was for a Single Line field, but the screenshot seems to indicate you want the value somewhere other than a field.

0 0
replied on December 19, 2019

It is a single line field. I have css applied to make it appear that way. "HIB" is also a Single line field. 

0 0
SELECTED ANSWER
replied on December 19, 2019 Show version history

Can you double check the form designer to make sure you're not getting an error? (make sure you refresh the page and double check the variable names all match up too)

Also, is it possible that your CSS is hiding an on-page error message?

With that calculation, there's no way it should just have a "blank" result unless there is some kind of error in the calculation or it isn't using the right variable(s).

Side note, don't put the = in front of the variable, it should be as follows:

=IF(COUNTIF(route.rig,"<>")>1,INDEX(route.rig,2),msr_destination)

That extra = sign should have prompted an error message, which is why I recommend refreshing the designer page after you set the calculation.

1 0
replied on December 19, 2019

it was the "=" in the variable and not refreshing. Problem solved. 

 

 

I appreciate the assistance, Jason.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.