ValidIf to prevent form from saving if another survey already exists

Eveningโ€ฆ

ValidIfโ€ฆ???

Iโ€™d like to prevent my survey_Form saving if any asset in [asset_name] also exists in the survey table [asset_name] column. This is to prevent a new survey starting from this survey_Form if a survey already exists.

Two things to note:

  1. [asset_name] is an EnumList Ref Type that uses a ValidIf to produce itโ€™s list from the asset table.

  2. When the survey_Form is saved an action extracts each name from [asset_name] and creates a new row for each in the survey table - so the survey table will always only have one name in [asset_name] even though itโ€™s an EnumList in the form.
    .
    .
    .
    The [asset_name] ValidIf is already in use so the approach Iโ€™ve been trying is for a separate column [validate_this_survey] to have a ValidIf that says:

NOT(
   IN(
   ANY([asset_name]),

SELECT(
	survey[asset_name],
	AND(
    [LCS] = [_THISROW].[LCS],
    [select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey]
    ))
    )
    )

.
Iโ€™m trying to force an error if any asset in [asset_name] also exists in the survey table but Iโ€™m failing.

Any assistance would be greatly appreciated.

Thanksโ€ฆ
.
.

survey_Form

survey table

0 9 821
9 REPLIES 9

Steve
Platinum 5
Platinum 5

Remove existing surveyed assets from this list using list subtraction, described here:

I didnโ€™t think of doing it that way roundโ€ฆ! Thanks @Steveโ€ฆ

Hi @Steve,

Thanksโ€ฆ Iโ€™ve now made some progress on the [validate_survey] column.

[validate_survey] now always matches [asset_name] except when the existing survey asset names from the survey table have been subtracted.

When that happens, [validate_survey] appears blank/empty. So I tried the following to trigger the error:.
.
[validate_survey] Valid If

ISNOTBLANK([validate_survey])

[validate_survey] Initial Value

[asset_name]
-
SELECT(
	survey[asset_name],
	AND(
    [LCS] = [_THISROW].[LCS],
    [select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
    NOT([branch_info] = "computed")
    ))

.
Sorry but thereโ€™s something about Valid If that I donโ€™t quite getโ€ฆ Please could you point out where Iโ€™m going wrongโ€ฆ?
.
.



That is exactly equivalent to no Valid If expression but setting Required? to ON. You should remove that Valid If expression and set Required? to ON.

The expression youโ€™re trying to construct (if I understand your goal correctly) should be in Valid If, not Initial value. By putting an expression that produces a list result inValid If, youโ€™ll be giving the user a dropdown list of valid options to choose from. The user wonโ€™t have an opportunity to choose an invalid option (if your expression is written properly).

In designing the Valid If expression, you want to generate a list of all possible valid values, the remove from that list the values that should not be available currently (i.e., because theyโ€™re in use elsewhere). How can you generate a list of all possible asset_name values (not just those currently in use)?

Hi @Steve,

Thanks for your detailed responseโ€ฆ

I am currently using a few Valid If expressions in my forms as you suggested and I use Initial Value expressions as well to pre-populate some Enum Lists.

I may have asked my original question badlyโ€ฆ

What Iโ€™m trying to do is invoke a โ€œData Validityโ€ situation so that I can force an โ€œInvalid Value Errorโ€ message (preventing a user from saving the form) until they select different form options that release the โ€œError Triggerโ€ i.e. the [asset_name] column.

I still havenโ€™t figured this one out!

.
.

Based on your previous suggestion, I went back into my [asset_name] Valid If and inserted a list to subtract any previously surveyed asset names which modifies the formโ€™s previous behaviour. Now the form will only show asset names that have not been started/finished previously. Thatโ€™s great thanks!
.

-SELECT(survey[asset_name],
	AND(
	[LCS] = [_THISROW].[LCS],
    [select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
    [sub_asset] = [_THISROW].[sub_asset],
    [select_asset_type] = [_THISROW].[select_asset_type],
    NOT([_THISROW].[branch_info] = "computed")
    ))

.
The result is that the [asset_name] column is BLANK in the form when it comes across a scenario where something was surveyed before i.e.

6 assets were proposed in the Enum List thenโ€ฆ
6 previously surveyed assets were discovered and subtracted andโ€ฆ
0 assets remain in Enum List and it disappears in the form (BLANK?)
.
Hereโ€™s an example where CAT6A has no asset names to display:
.
3X_e_a_ea335d095edbe04808ce28ef71d45bc05f57744d.png
.
And hereโ€™s one where Fibre does have asset names to display:
.


.
.
.
.

.
You may regret having asked this one as the inefficiency of these expressions is either going to make you laugh or cry so loud you may do yourself a mischiefโ€ฆ
.
.
.
.
[asset_name] Valid If

IFS(

[survey_type] = "Node",

ORDERBY(
	SELECT(asset[id],
	IN([id],
	SORT(
	UNIQUE(
	SELECT(rf_design[Source Asset ID],
	AND(
	[lcs] = [_THISROW].[lcs],
      [main_asset_name] = [_THISROW].[select_cabinet_to_survey],
      [sub_asset_name] = [_THISROW].[sub_asset],
      [source_asset_type] = [_THISROW].[select_asset_type],
    	NOT([_THISROW].[branch_info] = "computed"),
      NOT(
      	AND(
          LEFT([sub_asset_name], 3) = 'HPR',
      				[source_asset_type] = 'Fibre',
      				[destination_asset_type] = 'HPR'
      				))
      ))
	+SELECT(rf_design[Destination Asset ID],
	AND(
	[lcs] = [_THISROW-2].[lcs],
      [main_asset_name] = [_THISROW-2].[select_cabinet_to_survey],
      [sub_asset_name] = [_THISROW-2].[sub_asset],
      [destination_asset_type] = [_THISROW-2].[select_asset_type],
      NOT([destination_asset_type] = 'Cabinet'),
    	NOT([_THISROW].[branch_info] = "computed"),
      NOT(
      	AND(
          LEFT([sub_asset_name], 3) = 'HPR',
      				[source_asset_type] = 'Fibre',
		      		[destination_asset_type] = 'HPR'
    		  		)),
      NOT(
      	AND(
          		[main_asset_name] = [sub_asset_name],
      				[source_asset_type] = 'Fibre',
      				[destination_asset_type] = 'HPR'
      				))
      ))
	-SELECT(survey[asset_name],
	AND(
	[LCS] = [_THISROW].[LCS],
      [select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
      [sub_asset] = [_THISROW].[sub_asset],
      [select_asset_type] = [_THISROW].[select_asset_type],
    	NOT([_THISROW].[branch_info] = "computed")
      ))
      ),FALSE
			)),TRUE
			),[asset_name]
			),

[survey_branch_number] = 1,

ORDERBY(
	SELECT(asset[id],
	IN([id],
	SORT(
	UNIQUE(
	SELECT(rf_design[Source Asset ID],
	AND(
	[lcs] = [_THISROW].[lcs],
      [main_asset_name] = [_THISROW].[select_cabinet_to_survey],
      [sub_asset_name] = [_THISROW].[sub_asset],
      [source_asset_type] = [_THISROW].[select_asset_type],
    	NOT([_THISROW].[branch_info] = "computed"),
      NOT(
      		AND(
        	LEFT([sub_asset_name], 3) = 'HPR',
      		[source_asset_type] = 'Fibre',
      		[destination_asset_type] = 'HPR'
      		))
      ))
	+SELECT(rf_design[Destination Asset ID],
	AND(
	[lcs] = [_THISROW-2].[lcs],
      [main_asset_name] = [_THISROW-2].[select_cabinet_to_survey],
      [sub_asset_name] = [_THISROW-2].[sub_asset],
      [destination_asset_type] = [_THISROW-2].[select_asset_type],
      NOT([destination_asset_type] = 'Cabinet'),
    	NOT([_THISROW].[branch_info] = "computed"),
      NOT(
      	AND(
    		  LEFT([sub_asset_name], 3) = 'HPR',
  	   			[source_asset_type] = 'Fibre',
	     			[destination_asset_type] = 'HPR'
      				)),
      NOT(
      		AND(
          		[main_asset_name] = [sub_asset_name],
      				[source_asset_type] = 'Fibre',
      				[destination_asset_type] = 'HPR'
      				))
       ))
	-SELECT(survey[asset_name],
	AND(
	[LCS] = [_THISROW].[LCS],
      [select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
      [sub_asset] = [_THISROW].[sub_asset],
      [select_asset_type] = [_THISROW].[select_asset_type],
    	NOT([_THISROW].[branch_info] = "computed")
      ))
    	),FALSE
	)),TRUE
	),[asset_name]
	)

	-SPLIT(survey[planned_asset_id], ",")
	-[branch_A_assets]
	-[branch_B_assets]
	-[branch_C_assets]
	-[branch_D_assets]
	-[branch_E_assets],

[survey_branch_number] > 1,

SPLIT(
	SELECT(
	survey[survey_asset_id],
  	AND(
	[survey_type] = "Cable",
	[LCS] = [_THISROW].[lcs],
	[select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
	[sub_asset] = [_THISROW].[sub_asset],
    [select_asset_type] = [_THISROW].[select_asset_type],
    [survey_branch_number] = [_THISROW].[survey_branch_number],
    [branch_info] = "new branch"
    )),
    ","
    )

-SPLIT(
	SELECT(
	survey[planned_asset_id],
  	AND(
	[survey_type] = "Cable",
	[LCS] = [_THISROW].[lcs],
	[select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
    [sub_asset] = [_THISROW].[sub_asset],
	[select_asset_type] = [_THISROW].[select_asset_type],
    [originating_branch] = [_THISROW].[survey_branch_number],
    NOT([branch_info] = "computed")
    )),
    ","
    )

-SELECT(survey[asset_name],
	AND(
	[LCS] = [_THISROW].[LCS],
    [select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
    [sub_asset] = [_THISROW].[sub_asset],
    [select_asset_type] = [_THISROW].[select_asset_type],
    NOT([_THISROW].[branch_info] = "computed")
    ))
    
    -[branch_A_assets]
		-[branch_B_assets]
		-[branch_C_assets]
		-[branch_D_assets]
		-[branch_E_assets]

    )

.
.
.
.
[asset_name] Initial Value

IFS(

[survey_branch_number] = 1,

ORDERBY(
	SELECT(asset[id],
	IN([id],
	SORT(
	UNIQUE(
	SELECT(rf_design[Source Asset ID],
	AND(
	[lcs] = [_THISROW].[lcs],
      [main_asset_name] = [_THISROW].[select_cabinet_to_survey],
      [sub_asset_name] = [_THISROW].[sub_asset],
      [source_asset_type] = [_THISROW].[select_asset_type],
    	NOT([_THISROW].[branch_info] = "computed"),
      NOT(
		AND(
        	LEFT([sub_asset_name], 3) = 'HPR',
		[source_asset_type] = 'Fibre',
		[destination_asset_type] = 'HPR'
		))
      ))
	+SELECT(rf_design[Destination Asset ID],
	AND(
	[lcs] = [_THISROW-2].[lcs],
      [main_asset_name] = [_THISROW-2].[select_cabinet_to_survey],
      [sub_asset_name] = [_THISROW-2].[sub_asset],
      [destination_asset_type] = [_THISROW-2].[select_asset_type],
      NOT([destination_asset_type] = 'Cabinet'),
    	NOT([_THISROW].[branch_info] = "computed"),
      NOT(
      		AND(
    		  LEFT([sub_asset_name], 3) = 'HPR',
			[source_asset_type] = 'Fibre',
			[destination_asset_type] = 'HPR'
			)),
      NOT(
      		AND(
          		[main_asset_name] = [sub_asset_name],
			[source_asset_type] = 'Fibre',
			[destination_asset_type] = 'HPR'
			))
      ))
    	),FALSE
	)),TRUE
	),[asset_name]
	)

	-SPLIT(survey[planned_asset_id], ",")
	-[branch_A_assets]
	-[branch_B_assets]
	-[branch_C_assets]
	-[branch_D_assets]
	-[branch_E_assets],

[survey_branch_number] > 1,

SPLIT(
	SELECT(
	survey[survey_asset_id],
  	AND(
	[survey_type] = "Cable",
	[LCS] = [_THISROW].[lcs],
	[select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
	[sub_asset] = [_THISROW].[sub_asset],
    [select_asset_type] = [_THISROW].[select_asset_type],
    [survey_branch_number] = [_THISROW].[survey_branch_number],
    [branch_info] = "new branch"
    )),
    ","
    )

-SPLIT(
	SELECT(
	survey[planned_asset_id],
  	AND(
	[survey_type] = "Cable",
	[LCS] = [_THISROW].[lcs],
	[select_cabinet_to_survey] = [_THISROW].[select_cabinet_to_survey],
    [sub_asset] = [_THISROW].[sub_asset],
	[select_asset_type] = [_THISROW].[select_asset_type],
    [originating_branch] = [_THISROW].[survey_branch_number],
    NOT([branch_info] = "computed")
    )),
    ","
    )
    
    -[branch_A_assets]
	-[branch_B_assets]
	-[branch_C_assets]
	-[branch_D_assets]
	-[branch_E_assets]

    )

.
.
Cheersโ€ฆ

Thatโ€™s a lot to digest. What do you need from me at this point?

Hi @Steve,

Agreedโ€ฆ Please ignore everything aboveโ€ฆ Starting overโ€ฆ

What Iโ€™m trying to do is invoke a โ€œData Validityโ€ situation so that I can force an โ€œInvalid Value Errorโ€ message (preventing a user from saving the form) until they select different form options that release the โ€œError Triggerโ€

For example:

If the result of an expression in [Column A] is <=0

Then [column B] should have a (Data Validity) โ€œInvalid Value Errorโ€ message and prevent a user from saving the form until [Column A] is no longer <=0

I can deal with the expressions/conditions that create or resolve [Column A].

Iโ€™m having difficulty with [Column B]

Cheersโ€ฆ

Hi @Steve,

I think Iโ€™ve got it now.

It looks like I was making this more difficult than it needed to be.

Apologies for the wild goose chaseโ€ฆ

Iโ€™ll go and apply this in my app nowโ€ฆ Thanks for your timeโ€ฆ
.
.
Error Not Triggered
3X_f_d_fd86ab840376568ff0a0ef1c7b30889b833e87f1.png

Error Triggered by [data] < 1
3X_6_f_6fb6f13aae204070c336a48e42aaa6cb3a19f652.png

[validity_checker] column

[data] column

Top Labels in this Space