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 Reply Children
  • 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. :-(

  • 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;

  • 0 in reply to Conrad Roux

    Hey Conrad - when you enumerate your block values, how do you get the value of each block (field on screen)? I can get the field names, but not the values.

  • 0 in reply to Paul C

    OK - slightly weird - if I leave my code as is except I remark the line that inserts the second button (1st button is "Filter", 2nd button is "New Project") then the filtering works as it should.  Obviously there is no "New Project" button if I do this, but filtering works.  What have you done, Sage?

  • +1 in reply to Paul C
    verified answer

    It appears that if the PermissionsEntity and PermissionsType arguments are passed to the CRM.Button() method then filtering gets broken.  I am using these to control access to the New Project button to control which users can see the button.  If I remove the arguments then filtering works as it should and the New Project button is displayed (and works).  Oh well, it's only taken me a whole day (well, 12.5 hours actually) of unbillable time to figure this out.  Thanks, Sage.

  • 0 in reply to Paul C
    SUGGESTED

    Hi Paul,

    Sorry that it took you so long and that I was not of greater help to you. Can you show me what you did. If I can replicate this then we can escalate it.

    You could use logic in the code to display or not display the button (instead of permissions arguments), that should do the job, if I understand you correctly.

    To answer a previous question you had about the field values:
    When I need to get the value I assign the block to an enum, then loop the enum with item property, when I need to get the value of the item, you can just use Request.Form to get the value -> String(Request.Form(myE.item()))

    Hope this helps.

  • +1 in reply to Conrad Roux
    verified answer

    hi Conrad - you were a great help thanks!

    I removed the security arguments from the CRM.Button() method:

    //fbHtml += CRM.Button("New Project", "new.gif", CRM.URL("maProject/maProjectNew.asp")+"&E=maProject", 'maProject', 'insert');
    fbHtml += CRM.Button("New Project", "new.gif", CRM.URL("maProject/maProjectNew.asp")+"&E=maProject");

    The first line (remarked) is the original, replaced with the second line. Without the security arguments (, 'maProject', 'insert') filtering works!

    If you can replicate this then that would be good.

  • 0 in reply to Paul C

    Paul:  Can you please post a full working example for CRM 2020, I am having issues with filtering in 2020 as well.  Thanks!

  • 0 in reply to Michele Gaw

    hi Michele - I've tried posting the code three times but just get "there has been an error" messages so I've given up I'm afraid.

  • 0 in reply to Paul C

    Paul:  What you sent me in chat works!  Thank you very much!!!