Db.search and $REF

I am probably just blind, but would love fresh eyes to help.

I have to find all the responses to a document that are 1 of 2 types and then look at those for responses. I am trying to avoid looping through by doing a search through the many types of responses this document could have.

Can I not search with $REF or am I missing something stupid here ?

PISearch=|Form=“Project” & $REF=@DocumentUniqueID & StatusID>300 & StatusID<600 OR Form=“Inspection”&$REF=@DocumentUniqueID&StatusID=350|

Thanks in advance

Lisa

Subject: db.search and $REF

Lisa,

When you write $REF = @DocumentUniqueID, you are in both cases referring to the same document. What you probably want is, in English, “The $REF of the child document to equal the @DocID of the parent document,” right?

But this isn’t a valid db.search string.

Do you have a static DocID that you can substitute for @DocumentUniqueID? Maybe you meant that and I’m just being obtuse. If so, try things like @Text($REF) to make it easier to match against another string.

Also, use parens to make sure your search string ands/ors are treated correctly.

regards,

raphael

Subject: RE: db.search and $REF

Raphael

Thanks for the quick response, trust me I am the one being obtuse. My brain stopped a couple hours ago.

I have a building document. I need to find all the project and inspections that are it’s children with the specific statuses.

$REF contains the parent, so I was assuming it knew which bld doc I meant !@#.

Of course it doesn’t !! Sorry to waste your time. I need to create a variable with the building I had a hold of and hope I have all my “” in the right place !

Thanks again

Lisa

Subject: Thanks Raphael, can you/someone help with the syntax

I know it is a mess, but can you see where I messed up ?

bID is a variable containing the parent UNID.

PISearch=|(Form=“Project” & @Contains($REF;“{& bID &}”) & StatusID>300 & StatusID<600)OR (Form=“Inspection”& @Contains($REF;“{&bID&}”)&StatusID=350)|

Thx

Lisa

Subject: RE: Thanks Raphael, can you/someone help with the syntax

Lisa - try this:

PISearch=|(Form=“Project” & @Contains($REF;“| + bID + |”) & StatusID>300 & StatusID<600)OR (Form=“Inspection”& @Contains($REF;" | + bID + | ")&StatusID=350)|

  • you were using ‘&’ for concatenating strings in stead of ‘+’

  • your string terminators were mis-matched.

I don’t think you need to use @Contains either. Instead you can use : | @Text($Ref) = " | + bID + |"|

$Ref actually contains the UNID in hex form, and returns an error if you try to put it directly in a view, or compare it to a string. It requires explicit conversion to text.

Subject: Thanks Michelle !

Thanks for the quick reply, yours is a lot cleaner… I was pulling my hair out last night, I also had the OR in there and it should have been a |

A year off on mat leave and being thrown to the wolves really zaps the brain cells…

Cheers

Lisa