Syntax for AND / OR in fetch

Sep 2, 2010 at 11:56 PM

Can you please provide the syntax for a fetch that is as follows:

<fetch mapping='logical'>
  <entity name='new_spec'>
      <filter type='and'>
           <condition attribute='new_equipspecid' operator='eq' value='{73322B9D-4268-DF11-9C08-00188B48610C}'/>
      <filter type='or'>
           <condition attribute='new_type' operator='eq' value='2'/>
           <condition attribute='new_type' operator='eq' value='3'/>

Many thanks - Great plug-in!
John Foley

Dec 9, 2010 at 3:32 PM

I create a new entity called Ägreement"with the schema name new_agreement

I then create a loop attribute on this entity to the accounts entity called "new_customerïd"

I now want to lookup the agreements for a customer from the quote entity / form.

I added the following javascript after I register the plug-in and set the windows registry entry.

var field = crmForm.all.new_agreementid;
if(crmForm.all.customerid.DataValue == null)
    // Disable lookup if we do not a prefered customer
    field.Disabled = true;
    // Enable lookup if customer exists
    field.Disabled = false;

    // Ensure that search box is not visible in a lookup dialog
    field.lookupbrowse = 1;
    // fetch xml through filter value parameter
          "<fetch mapping='logical'>"
        +    "<entity name='new_agreement'>"
        +      "<filter type='and'>"
        +         "<condition attribute='new_customerid' operator='eq' "
        +            "value='" + crmForm.all.customerid.DataValue[0].id + "'"
        +         "/>"
        +      "</filter>"
        +    "</entity>"
        + "</fetch>"

This open the agreement lookup view but do not display any values.

I also updated the agreement lookup view and included the "Customer" attribute in the find columns

Any suggestion ?

Dec 9, 2010 at 8:02 PM

Try this:


var fetchEnt = "new_agreement";
var fetchCondAtt1 = "new_customerid";
var fetchOp1 = "eq";
var fetchVal1 = crmForm.all.customerid.DataValue[0].id;

var fetchStr = "<filters>"
             + "<filter entity=\""
             + fetchEnt
             + "\""
             + "><condition attribute=\""
             + fetchCondAtt1 
             + "\" operator=\""
             + fetchOp1 
             + "\" value=\""
             + fetchVal1
             +  "\" /></filter></filters>";

field.AddParam('filters', fetchStr);

[ Take note that the use of single quote for the 'filters' parameter, you used double quotes...  the plugin reverses the usual quote mark convention ]

Good luck, JF