Help with Windows legacy throwing a compile error when using IF activity

Using the same variables (same code) in my IF condition, windows-legacy is throwing a compile error that appears to a type-mismatch, but the same code (if conditions) works perfectly on Windows version.


We would assume different misusages.
Can yout tell us the sample value from sheetName Variable?
Thanks

1 Like

@yomi.oluwadara

Looks like the split function is misused…if you see you are not providing any delimiter…only string input is provided

cheers

1 Like

image

Screenshot shows its assignment and an example of its value. All other possible values in the FOR

“Added HCPCS Codes”

“Deleted HCPCS CPT Codes”

“Modified HCPCS Code Descriptions”

“Reason Key: A=Added To List, N=New Code”

We are not sure if the input or the output is meant and has the value deleted. We also do see a different construct, not same to the above screenshots

We do feel that a proper requirement/value would speed up the answer. However, let’s start.
Regardless if there are some passing validations, we would state

  • When using First/FirstOrDefault Linq Operator and passing some arguments on it (i+1).toString) it is against the defined method signature. We do see the complained string received, but lambda with Boolean output is expected

Legacy:

EDITED: Thanks to @supermanPunch for bringing the new feature into the picture (post below) :+1:
vs. Windows:

So more and more we risk drifting away from the needed output by the given input

Maybe you can elaborate more on what is given and what is needed. Thanks

1 Like

@ppr Thanks for the input. Apologies, I have updated my reply to include the accurate value (see screenshot) of the variable sheetName . Does this new information help ?

full package is welcome

lets go another small step

grafik

sampling was done within the immediate panel ( you can also use)

A first() would extract Added or Reason. We guess that those values are not the expected SheetNames

1 Like

Hi @yomi.oluwadara ,

The specification of Default value with FirstOrDefault() should be possible with Windows versions but in the Legacy it is not possible, as for the Legacy projects, the .Net versions are lesser than .Net 6.

So, the replacement would be to use the Method as suggested by @ppr for Legacy Projects

1 Like

@supermanPunch and @ppr
For this code to work in legacy, should the code:
sheetNamesAdded.Contains(Split(sheetName).FirstOrDefault((i+1).ToString)) = true

Should essentially become
sheetNamesAdded.Contains(Split(sheetName).DefaultIfEmpty()) = true ?

Looking at the resource Enumerable.DefaultIfEmpty Method (System.Linq) | Microsoft Learn , I would think invoking the DefaultIfEmpty() should work, but it does not

@yomi.oluwadara ,

Could you let us know what did not work ? Was there a Compiler error like before or did it not return the Expected result ?

Let us know what is the Expectation from this change in code.

1 Like

still we have doubts on the split part and what is tried

in addition to the LINQ training in legacy we can do
grafik

for demo purpose we did a where fitlering, with resulting empty filterresult, and returned the default value.

But your involved split construct will react as
grafik

1 Like

@supermanPunch


Here is the error and attached is the windows legacy project itself.
regexTableProj.zip (690.2 KB)

I’m still confused about the error.

if we would rewrite to:
sheetNamesAdded.Contains(Split(sheetName).DefaultIfEmpty((i+1).toString()).First()) = true

we would adapt. But still we have doubts if implementation is matching expectation

1 Like

@ppr and @supermanPunch The DefaultIfEmpty worked and I’m getting my expected behavior.Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.