RibbonWorkbench icon indicating copy to clipboard operation
RibbonWorkbench copied to clipboard

Run Report smart button NOT executing on the current record

Open anasraf opened this issue 7 years ago • 5 comments

Hi there,

I used your solution in running workflows and quick javascript it works fine. but when i try to run a report from a smart button it doesn't run on the current record it just executing on a random record i checked the passed parameters and it looks everything is fine. Thank you in advance for your time.

anasraf avatar Feb 19 '18 16:02 anasraf

Could you post the link that is being opened compared to the link that you expect to be opened? Thanks!

scottdurow avatar Apr 06 '18 16:04 scottdurow

Hey Guys! I tried this solution and i get the same problem. Analysis : Link by the standard button : https://org.crm4.dynamics.com/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=Bon%20de%20commande%20parent.rdl&id=%7baad4ac08-4c7b-e711-80fe-5065f38b4641%7d&records=%7bEA75A694-7A20-E811-8115-5065F38BE571%7d&recordstype=10059 Link opened by ur smart button : https://org.crm4.dynamics.com/crmreports/viewer/viewer.aspx?action=run&id=%7baad4ac08-4c7b-e711-80fe-5065f38b4641%7d&records=%7b{EA75A694-7A20-E811-8115-5065F38BE571}%7d&recordstype=10059

After some testing : When i execute the smart button i have a report on an other record (but not random, it seem to be the same everytime). Using the link opened by smart button, we just have to add "&context=records" and remove the "{" in the Guid's value "records=" . We dont really need to specify the "helpID=", it works without.

Solution : btw u have to apply some changes on lines 2096 in SmartButtons.ClientHooks.js : '/crmreports/viewer/viewer.aspx?action=run&id=%7b'+encodeURIComponent($1_2)+'%7d&records=%7b'+recordId+'%7d&recordstype='+etc;

  1. remove "{" in recordId var
  2. add this : '/crmreports/viewer/viewer.aspx?action=run&**context=records&**id=%7b'+encodeURIComponent($1_2)+'%7d&records=%7b'+recordId+'%7d&recordstype='+etc;
  3. helpId : it should be add because it's cleaner , it's the report's name

Hope that will help you and many thanks about your works ! Best Regards,

Note : You can use this function for replace the "{" in the recordId's var function formatId(entityId) { if (entityId != null) { return entityId.replace("{", "").replace("}", ""); } return null; }

allandecastro avatar Jul 31 '18 15:07 allandecastro

Hello Allan, I am receiving the same issue. I tried to amend the SmartButtons.ClientHooks.js file as mentioned in your comment but without any luck. Could you please send me your SmartButtons.ClientHooks.js file. Thank you.

EmanWah avatar Oct 07 '19 14:10 EmanWah

What we have to do is replace the Ribbon Javascript.

Create a new solution and add the JS named "dev1_/js/SmartButtons.ClientHooks.js". Then change the report URL in line 2096:

OLD LINE: '/crmreports/viewer/viewer.aspx?action=run&id=%7b'+encodeURIComponent($1_2)+'%7d&records=%7b'+recordId+'%7d&recordstype='+etc;

NEW LINE: '/crmreports/viewer/viewer.aspx?action=run&context=records&id='+encodeURIComponent($1_2)+'&records='+recordId+'&recordstype='+etc+'&helpID='+reportName;

That solved my problem!

anasraf avatar Oct 07 '19 14:10 anasraf

Your solution solved my problem...Many Thanks!

EmanWah avatar Oct 08 '19 04:10 EmanWah