Number Expected? Sorry guys

OK, I give up.This formula works OK, but is no good for the application anymore (need to remove @IsNewDoc part):

tProjectLeadIT:=

@If(@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“No”;Name1;

@If(@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“Yes”;Sub1;

@If(@Contains(All2;“Project Lead (IT)”) & Sub2Yes=“No”;Name2;

@If(@Contains(All2;“Project Lead (IT)”) & Sub2Yes=“Yes”);Sub2;

@If(@Contains(All3;“Project Lead (IT)”) & Sub3Yes=“No”;Name3;

@If(@Contains(All3;“Project Lead (IT)”) & Sub3Yes=“Yes”);Sub3;

@If(@Contains(All4;“Project Lead (IT)”) & Sub4Yes=“No”;Name4;

@If(@Contains(All4;“Project Lead (IT)”) & Sub4Yes=“Yes”);Sub4;

@If(@Contains(All5;“Project Lead (IT)”) & Sub5Yes=“No”;Name5;

@If(@Contains(All5;“Project Lead (IT)”) & Sub5Yes=“Yes”);Sub5;

@If(@Contains(All6;“Project Lead (IT)”) & Sub6Yes=“No”;Name6;

@If(@Contains(All6;“Project Lead (IT)”) & Sub6Yes=“Yes”);Sub6;

@If(@Contains(All7;“Project Lead (IT)”) & Sub7Yes=“No”;Name7;

@If(@Contains(All7;“Project Lead (IT)”) & Sub7Yes=“Yes”);Sub7;

@If(@Contains(All8;“Project Lead (IT)”) & Sub8Yes=“No”;Name8;

@If(@Contains(All8;“Project Lead (IT)”) & Sub8Yes=“Yes”);Sub8;

@If(@Contains(All9;“Project Lead (IT)”) & Sub9Yes=“No”;Name9;

@If(@Contains(All9;“Project Lead (IT)”) & Sub9Yes=“Yes”);Sub9;

@If(@Contains(AllA;“Project Lead (IT)”) & SubAYes=“No”;NameA;

@If(@Contains(AllA;“Project Lead (IT)”) & SubAYes=“Yes”);SubA;

@If(@Contains(AllB;“Project Lead (IT)”) & SubBYes=“No”;NameB;

@If(@Contains(AllB;“Project Lead (IT)”) & SubBYes=“Yes”);SubB;

@If(@Contains(AllC;“Project Lead (IT)”) & SubCYes=“No”;NameC;

@If(@Contains(AllC;“Project Lead (IT)”) & SubCYes=“Yes”);SubC;

@If(@Contains(AllD;“Project Lead (IT)”) & SubDYes=“No”;NameD;

@If(@Contains(AllD;“Project Lead (IT)”) & SubDYes=“Yes”;SubD;

“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”)))))))))))))));

@If(@IsNewDoc;“”;

@If(tProjectLeadIT=“” & Boss=“”;“”;@If(tProjectLeadIT=“” & Boss!=“”;@Name([CN];Boss);@Name([CN];Boss):tProjectLeadIT)))

Then, take out this line, @If(@IsNewDoc;“”;

and I get “Incorrect data Type for operator or @Function, Number Expected”???

Why is it expecting a number, it’s a text field, not number, anyone know how I can get rid of this error once and for all??

Ta

Generic

Subject: Number Expected??? Sorry guys…

Do you realize that you can chain @If statements. In other words, where you have:

tProjectLeadIT:=

@If(@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“No”;Name1;

@If(@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“Yes”;Sub1;

@If(@Contains(All2;“Project Lead (IT)”) & Sub2Yes=“No”;Name2;

@If(@Contains(All2;“Project Lead (IT)”) & Sub2Yes=“Yes”);Sub2;

…

@If(@Contains(AllD;“Project Lead (IT)”) & SubDYes=“No”;NameD;

@If(@Contains(AllD;“Project Lead (IT)”) & SubDYes=“Yes”;SubD;

“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”;“”)))))))))))))));

You could have:

tProjectLeadIT:=

@If(@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“No”;Name1;

    @Contains(All1;"Project Lead (IT)") & Sub1Yes="Yes";Sub1;



    @Contains(All2;"Project Lead (IT)") & Sub2Yes="No";Name2;

    @Contains(All2;"Project Lead (IT)") & Sub2Yes="Yes";Sub2;

…

   @Contains(AllD;"Project Lead (IT)") & SubDYes="No";NameD;

   @Contains(AllD;"Project Lead (IT)") & SubDYes="Yes";SubD;



    "");

This may at least help with debugging.

Subject: Number Expected??? Sorry guys…

To start with, I do not think that the “number expected” error is coming from the above code. It must be a field formula, right? It simply returns a value. What is the context?

Second, it would be more readable to use a single @If statement rather than a big pile of nested @Ifs. Something like this:

tProjectLeadIT:=

@If(@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“No”;Name1;

@Contains(All1;“Project Lead (IT)”) & Sub1Yes=“Yes”;Sub1;

@Contains(All2;“Project Lead (IT)”) & Sub2Yes=“No”;Name2;

@Contains(All2;“Project Lead (IT)”) & Sub2Yes=“Yes”);Sub2;

…

Also, what value is @Contains providing? Is it not an exact match? Otherwise, an equals sign would be cleaner.

Subject: RE: Number Expected??? Sorry guys…

Yes it’s a field formula.

e.g. the error occours if you try and create a new document, it specifies the fieldname and then the error I included in the first one.

Later on when I have some more time I’ll re-work the @If statement, to see if it helps without so many ifs - certainly that would be less code and clearer what is going on…

Subject: RE: Number Expected??? Sorry guys…

Hi Generic,

It seems to be wierd. Are you sure that the error “…Number expected …” comes from this computed field formula? Check other number fields too for any such error. Also Try putting @Trim to the list as :

@Trim(@Name([CN];Boss):tProjectLeadIT)


Got sometime to work on it this morning. Try using this simplified formula: (Good for 1 to 10 and A,B,C,D variables.)

@For(n := 1; n <= 14; n := n + 1;

@If(n <= 10; x := @Text(n); x:= @Text(@Char(n+54)));

tProjectLeadIT:= @Text(@If((@Contains(@GetField(“All” +x);“Project Lead (IT)”) & @GetField(“Sub”+x+ “Yes”) =“No”); @GetField(“Name”+x); @If((@Contains(@GetField(“All” + x);“Project Lead (IT)”) & @GetField(“Sub” + x+“Yes”) =“Yes”); @GetField(“Sub”+x);“”))));

@If(@IsNewDoc; “”;

@If(tProjectLeadIT= “” & Boss=“”; “”;

  tProjectLeadIT= "" & Boss != ""; @Name([CN];Boss);

  tProjectLeadIT != "" & Boss = ""; @Name([CN]; tProjectLead); ----> (If you wish you can add this line)

@Trim(@Name([CN];Boss) : tProjectLeadIT)))

Subject: Is it COBOL ? arf no, we can emulate loops in COBOL, sorry

Subject: Number Expected??? Sorry guys…

@If(@IsNewDoc;“”;

@If(tProjectLeadIT=“” & Boss=“”;“”;@If(tProjectLeadIT=“” & Boss!=“”;@Name([CN];Boss);@Name([CN];Boss):tProjectLeadIT)));“”

Remove what’s in red and add a ;“” in blue?

JYR

Subject: RE: Number Expected??? Sorry guys…

Thanks, that avoids the error :-)It still doesn’t do what I want tho, so I suppose there must be a more fundamental problem with my plan or my code or something…

e.g. My field can still get set to blank if the user doesn’t press the ‘Refresh’ button…