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!

image

  • 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… :slight_smile:

.
.
.
survey table

.
.
.
survey form

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.

4 Likes

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… :slight_smile:

Brilliant…!!!

2 Likes

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?

3 Likes

Hi @Suvrutt_Gurjar,

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

Cheers… :blush:

1 Like

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’
3 Likes