Painted myself into a corner with ValidIf

Hi,

I’ve painted myself into a corner with ValidIf

My app uses the concept of current and planned cable routes / branches.

Current branches should always show in the survey form.
Current branch = [survey_branch_number]

Planned branches should only show in survey form when added via a LINKTOFORM action.
Planned branch = [branch_A_number] & [branch_B_number]

  • LINKTOFORM brings the planned [branch_A_number] into the current [survey_branch_number]
LINKTOFORM(
		"survey_Form",
		"lcs", [lcs],
		"select_cabinet_to_survey", [select_cabinet_to_survey],
		"select_asset_type", [select_asset_type],
		"asset_name", [branch_A_assets],
		"survey_branch_number", [branch_A_number],
        )
  • The ValidIf I was using gave me a result of 1, 2, 3, 4, 5
SORT(
	UNIQUE(
			SELECT(survey[survey_branch_number], TRUE, TRUE),          {1,2}
			 +SELECT(survey[branch_A_number], TRUE, TRUE)              {2,3,4}
			 +SELECT(survey[branch_B_number], TRUE, TRUE)              {5}

			-LIST(0)
			-LIST("")
			)
	)
  • But I only want to see the current [survey_branch_number] in the form
  • So I changed the ValidIf to give a result of 1, 2
SORT(
	UNIQUE(
		INTERSECT(
					SELECT(survey[survey_branch_number], TRUE, TRUE),       {1,2}

					SELECT(survey[survey_branch_number], TRUE, TRUE)        {1,2}
					+SELECT(survey[branch_A_number], TRUE, TRUE)            {2,3,4}
					+SELECT(survey[branch_B_number], TRUE, TRUE)            {5}

					-LIST(0)
					-LIST("")
				)
			)
		)
  • The problem now is LINKTOFORM throws an error when trying to add branch 3 or 4 or 5 because the ValidIf has ‘concealed’ them!

3X_7_3_7321550a186a89cea185218ceb015140d2e11a32.png

  • Is there a way to make my ValidIf a little ‘smarter’ so that it only shows items in [survey_branch_number] and then adapts to ‘see’ [branch_A_number] when the LINKTOFORM initiates a new form?

I hope that made sense?

Thanks in advance…

.
.
.
survey table

.
.
.
survey form

Solved Solved
0 6 277
1 ACCEPTED SOLUTION

If I have understood your requirement correctly, you may try following

You may create another “survey_Form” form view (Ref type) called say “surevy_Form_Action” by copying the existing survey_Form.

You may navigate tho this copied “survey_Form_Action” through LINKTOFORM() action.

LINKTOFORM(
"survey_Form_Action",
“lcs”, [lcs],
"select_cabinet_to_survey


)

In valid_if you may have an expression something like below

IFS(
CONTEXT(“View”)= “survey_Form”, LIST(1,2),
CONTEXT(“View”)= “survey_Form_Action”, LIST(1,2,3,4,5,6)
)

Of course you may need to include suitable expressions for LIST(1,2) and LIST(1,2,3,4,5,6), but the idea is vary the valid_if expression and list based on form view and use two forms -one for action and the other for normal use.

Actual implementation will depend on how your app is structured and other business logic. So please evlauate it.

View solution in original post

6 REPLIES 6

If I have understood your requirement correctly, you may try following

You may create another “survey_Form” form view (Ref type) called say “surevy_Form_Action” by copying the existing survey_Form.

You may navigate tho this copied “survey_Form_Action” through LINKTOFORM() action.

LINKTOFORM(
"survey_Form_Action",
“lcs”, [lcs],
"select_cabinet_to_survey


)

In valid_if you may have an expression something like below

IFS(
CONTEXT(“View”)= “survey_Form”, LIST(1,2),
CONTEXT(“View”)= “survey_Form_Action”, LIST(1,2,3,4,5,6)
)

Of course you may need to include suitable expressions for LIST(1,2) and LIST(1,2,3,4,5,6), but the idea is vary the valid_if expression and list based on form view and use two forms -one for action and the other for normal use.

Actual implementation will depend on how your app is structured and other business logic. So please evlauate it.

Hello again @Suvrutt_Gurjar,

An excellent suggestion and I can see exactly how that’s going to work. I’ll get on with implementing that and will report back. Thanks a million…

Brilliant…!!!
3X_8_7_87636a9d1545bc0bae542f38786278892311cb0a.gif

Good to know that the suggested approach can be useful. Please do evaluate it well as your app in general seems to be substantially large.

I may also suggest you to evaluate to simplify the above expression. It seems to create a big list by including SELECT(survey[survey_branch_number], TRUE, TRUE) in that big list and through intersecting again by SELECT(survey[survey_branch_number], TRUE, TRUE) it seems to get back to list comprised by expression SELECT(survey[survey_branch_number], TRUE, TRUE)

So you may wish to eveluate why not use just SELECT(survey[survey_branch_number], TRUE, TRUE) to start with instead of first creating a big list and then again truncating it through same means?

Hi @Suvrutt_Gurjar,

Thanks for that tip. Now that I have your other suggestion I will be able to simplify the above too.

Cheers…

Curvy Gyals is a body shapewear brand that is dedicated to empowering women of all shapes and sizes to feel confident and comfortable in their own skin. The brand offers a wide variety of shapewear products, including waist trainers, body shapers, fajas, and buttock lifters. Curvy Gyals shapewear is made with high-quality materials and construction, and it is designed to provide maximum compression and support. The brand also offers custom shapewear, so you can be sure to find the perfect fit for your body.

A note for users of XY Map:

Whilst the above solution worked perfectly - I did have some XY Map related issues.

I found that the new form (Survey_Form_action) had hijacked the existing form (Survey_Form) on my ‘Survey View’.

The solution to this was:

  • create a slice of the survey table called ‘Survey (Action)’
  • create a copy of the ‘Survey View’ and call it ‘Survey (Action) View’
  • point ‘Survey (Action) View’ to ‘Survey (Action)’ slice
  • point ‘survey_From_Action’ to ‘Survey (Action)’ slice
  • ask the LINKTOFORM to look at ‘Survey_Form_Action’

Hijack situation over!

  • ‘Survey View’ fires ‘Survey_Form’
  • ‘Survey (Action) View’ fires ‘Survey_Form_Action’
Top Labels in this Space