CRM 2020 R1 ArgObj property not working?

SOLVED

List=CRM.GetBlock("maProjectUserGrid");
List.prevURL=sURL;

FilterBox=CRM.GetBlock("maProjectUserFilterBox");
FilterBox.NewLine = false;
FilterBox.DisplayForm = false;
FilterBox.DisplayButton(Button_Default) = false;
FilterBox.ButtonLocation=Bottom;
FilterBox.ShowValidationErrors = false;
FilterBox.RefreshFromContent = true;

container = CRM.GetBlock('container');
container.AddBlock(List);
List.ArgObj = FilterBox;

I've used code similar to this for years.  With CRM 2020 R1 the filter does nothing.  In the SQL logs from CRM 2018 and CRM 2020 R1 after clicking the 'Filter' button:

CRM 2018:

Apr 7 2020 13:43:43.332 5648 5056 3 fselectsql,time,sql 79 select count(*) as fcount from vmaProject  WITH (NOLOCK)  WHERE (prjct_UserId=1 OR prjct_LeadConsultant=1 OR prjct_Consultant2=1 OR prjct_Consultant3=1) AND  prjct_stage = N'Planning'
Apr 7 2020 13:43:43.348 5648 5056 3 fselectsql,time,sql 15 SELECT prjct_referenceid, prjct_salesorderno, prjct_name, prjct_stage, prjct_status, prjct_golivedate, prjct_companyid, prjct_maprojectid FROM ( select prjct_referenceid, prjct_salesorderno, prjct_name, prjct_stage, prjct_status, prjct_golivedate, prjct_companyid, prjct_maprojectid , ROW_NUMBER() over(ORDER BY  prjct_referenceid DESC , prjct_maProjectID DESC ) AS rowranking  from vmaProject  WITH (NOLOCK)  WHERE (prjct_UserId=1 OR prjct_LeadConsultant=1 OR prjct_Consultant2=1 OR prjct_Consultant3=1) AND  prjct_stage = N'Planning'  ) as A  WHERE rowranking > 0 and rowranking < 11


CRM 2020:

Apr 7 2020 14:26:31.704 3392 4284 3 fselectsql,time,sql 0 select count(*) as fcount from vmaProject  WITH (NOLOCK)  WHERE (prjct_UserId=1 OR prjct_LeadConsultant=1 OR prjct_Consultant2=1 OR prjct_Consultant3=1)
Apr 7 2020 14:26:31.710 3392 4284 3 fselectsql,time,sql 0 SELECT prjct_referenceid, prjct_salesorderno, prjct_name, prjct_stage, prjct_status, prjct_golivedate, prjct_companyid, prjct_maprojectid FROM ( select prjct_referenceid, prjct_salesorderno, prjct_name, prjct_stage, prjct_status, prjct_golivedate, prjct_companyid, prjct_maprojectid , ROW_NUMBER() over(ORDER BY  prjct_referenceid DESC , prjct_maProjectID DESC ) AS rowranking  from vmaProject  WITH (NOLOCK)  WHERE (prjct_UserId=1 OR prjct_LeadConsultant=1 OR prjct_Consultant2=1 OR prjct_Consultant3=1)  ) as A  WHERE rowranking > 0 and rowranking < 11

Clearly in CRM 2018 the WHERE clause is expanded to include the Filterbox field 'prjct_stage', but not in CRM 2020 R1.

Has anyone else seen this?

Is there a workaround?

Thanks, Paul

Parents
  • 0

    Hi Paul,

    On my side it works perfectly. Have you tested manually setting the ArgObj with a string and then execute the block? I use an enumerator to loop my block values and add it to my string arg which I then add back to the ArgObj, and that seems to work fine.

  • 0 in reply to Conrad Roux

    Thanks Conrad.  Yes, it works if I hard-code the filter criteria as a string.  In previous CRM versions, assigning the filterbox object to the ArgObj property worked perfectly, but with CRM 2020 none of my filters work anymore.  The CRM 2020R1 developer guide still has examples of assigning a block to the ArgObj property so I think it should still work.  It looks like I'll be busy fixing filter boxes at a lot of sites when users upgrade. :-(

Reply
  • 0 in reply to Conrad Roux

    Thanks Conrad.  Yes, it works if I hard-code the filter criteria as a string.  In previous CRM versions, assigning the filterbox object to the ArgObj property worked perfectly, but with CRM 2020 none of my filters work anymore.  The CRM 2020R1 developer guide still has examples of assigning a block to the ArgObj property so I think it should still work.  It looks like I'll be busy fixing filter boxes at a lot of sites when users upgrade. :-(

Children
  • 0 in reply to Paul C

    Let me try assigning the obj rather than a string and see what it does on my side.

  • 0 in reply to Conrad Roux

    Passing the object works fine -
    Getting the partail SQL logs as:
    ...test_name LIKE N'conrad%' ESCAPE '|' AND  test_status = N'InProgress' AND test_userid = 1 AND test_Deleted is null... 

  • 0 in reply to Conrad Roux

    OK - it's definitely not working here.  Could you post your code?

  • 0 in reply to Paul C

    Hi Paul,

    I did notice something now. It seems that when I submit once, it does not add to the argobj, however on the second submit it does add it. I recall something like this in earlier versions of CRM and I had a workaround somewhere that I used, to basically just do a blank submit and then the "real" submit after that. I can't remember how I did it, but I will look for my code.

    Perhaps try that and see if it does what I mentioned.

    Here is my slimmed down page code:

    var filterBox = CRM.GetBlock("TESTFilterBox");
    filterBox.NewLine = false;
    
    var objContainer = CRM.GetBlock("container");
    
    objContainer.AddBlock(objList);
    objContainer.AddBlock(filterBox);
    objContainer.DisplayButton(Button_Default) = false;
    
    with (filterBox) 
    { 
    NewLine = false; 
    AddButton(strFilterButton);
    ButtonLocation = Bottom; 
    ButtonAlignment = Left; 
    } 
    
    objList.ArgObj = filterBox;