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

    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.

Reply
  • +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.

Children