You need to sign in to do that
Don't have an account?
Javascript to parse fields to Joined Report
Hi,
As a complete Javascript novice, I'm trying to get some assistance here with a script to run a report from a button on the Contracts object that will parse some field data to a joined report. You can't do it with a URL hack, has to be javascript.
Luckily, I have some code to work from, it is rather transparent although I need some help amending it.
My issue is with pulling some information from Salesforce into the script, arrays and such things.
Essentially the code I have ripped is looking to parse one field, I am looking to parse two (a custom field from the Accounts object (sagecode__c for arguments sake) and one from the Contracts object itself (contractnumber__c for arguments sake).
This is the code, it is from the author so does not contain anything pertaining to what I am aiming to do in my own org. The header comments are mine.
// JScript source code // This is a script which parses parameters to a Joined Report as URL hacking will not work in this instance. // Background reading on solution is here: http://salesforce.stackexchange.com/questions/8723/passing-variables-to-joined-reports // This script was sourced from here: https://gist.github.com/stephenbrown1/7443749 // Chrome extention tools to debug the report from here: http://forums.chrispederick.com/ // -- -- -- Click FORMS and VIEW FORM INFORMATION to find the reportJson details for this script after running report. // This site URL encodes the JSON request: http://www.freeformatter.com/url-encoder.html // Code is annotated where you need to make amendments var url = "/00O90000004ewmO"; // report ID var method = "POST"; var idArray = {!GETRECORDIDS($ObjectType.Contract_Partner_vod__c)}; // if the field you want for report critiera isn't avail from the detail record (ie list button) then need to get related data var idToUse = idArray[0]; //alert(idToUse); if (idToUse == null) { // need to have at least 1 record selected alert('You must select one contract partner record to run this report.'); } else { {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} result = sforce.connection.query("Select Id, Contract_vod__c from Contract_Partner_vod__c where Id = \'" + idToUse + "\'"); var contrId = null; records = result.getArray("records"); for (var i=0; i< records.length; i++) { var record = records[i]; contrId = record.Contract_vod__c.substring(0,15); } //alert(contrId); // if the field you want for report critiera isn't avail from the detail record (ie list button) then need to get related data - in this case contract ID // next line is post data - needs to be URL encoded. Note this is based on what comes from the runReportJson which you can get from running the report and checking firebug var postData = "op=run&runReportJson=%7B%22last_modified_user_id%22%3A%22005900000022hZg%22%2C%22breaks%22%3A%5B%7B%22brkcol%22%3A%2200N90000007QeT8%22%2C%22break%22%3A%2200N90000007QeT8%22%2C%22sortColumn%22%3A%2200N90000007QeT8%22%2C%22brkord%22%3A%22up%22%2C%22breakLevel%22%3A%220%22%2C%22brkdat%22%3A%220%22%7D%5D%2C%22colorRanges%22%3A%5B%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22reln%22%3A%2200N90000007JDQt%22%2C%22currency%22%3A%22000%22%2C%22id%22%3A%2200O90000004ewmO%22%2C%22cust_devName%22%3A%22Contract_Price_List%22%2C%22cust_name%22%3A%22Contract+Price+List%22%2C%22last_modified_by%22%3A%22Paul+Hosking%22%2C%22details%22%3A%22no%22%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22lsk%22%2C%22value%22%3A%221%22%7D%2C%7B%22param%22%3A%22block_id_counter%22%2C%22value%22%3A%226%22%7D%5D%2C%22templateKey%22%3A%2201I900000018lXc00N90000007JDQt%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%5D%2C%22sortdir%22%3A%22down%22%2C%22sideBySide%22%3Afalse%2C%22blocks%22%3A%5B%7B%22templateKey%22%3A%2201I900000018lXc00N90000007JDQt%22%2C%22scope%22%3A%22organization%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%22FK_NAME%22%2C%22CUST_NAME%22%2C%2200N90000007QeUH%22%2C%2200N90000007QeT7%22%5D%2C%22last_modified_user_id%22%3A%22%22%2C%22sideBySide%22%3Afalse%2C%22sortdir%22%3A%22up%22%2C%22breaks%22%3A%5B%5D%2C%22a%22%3A%5B%2200N90000007QeT7%22%2C%2200N90000007QeUH%22%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22colorRanges%22%3A%5B%5D%2C%22reln%22%3A%2200N90000007JDQt%22%2C%22format%22%3A%22t%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22v%22%3A142%2C%22cust_name%22%3A%22Contract+Price+Rule%22%2C%22co%22%3A%22no%22%2C%22last_modified_date%22%3A%22%22%2C%22last_modified_by%22%3A%22%22%2C%22details%22%3A%22no%22%2C%22customAggregates%22%3A%5B%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%2C%22blockId%22%3A%22B1%22%2C%22csfReferences%22%3A%5B%22FORMULA1%22%2C%22FORMULA2%22%2C%22FORMULA3%22%2C%22FORMULA4%22%2C%22FORMULA5%22%2C%22FORMULA6%22%2C%22FORMULA7%22%5D%7D%2C%22rt%22%3A%2251%22%2C%22filters%22%3A%5B%7B%22pc%22%3A%22FK_CUSTENT_ID%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22" + contrId + "%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%5D%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22colDt_c%22%2C%22value%22%3A%2200N90000007QeY2%22%7D%2C%7B%22param%22%3A%22colDt_e%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22colDt_q%22%2C%22value%22%3A%22custom%22%7D%2C%7B%22param%22%3A%22colDt_s%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22function%22%2C%22value%22%3A%22c%22%7D%2C%7B%22param%22%3A%22name_op%22%2C%22value%22%3A%22co%22%7D%2C%7B%22param%22%3A%22save_drill%22%2C%22value%22%3A%22true%22%7D%5D%7D%2C%7B%22templateKey%22%3A%2201I900000018lXc%22%2C%22scope%22%3A%22organization%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%22CUST_NAME%22%2C%2200N90000007QeT6%22%5D%2C%22last_modified_user_id%22%3A%22%22%2C%22breaks%22%3A%5B%5D%2C%22sideBySide%22%3Afalse%2C%22sortdir%22%3A%22up%22%2C%22a%22%3A%5B%2200N90000007QeT6%22%5D%2C%22colorRanges%22%3A%5B%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22format%22%3A%22t%22%2C%22v%22%3A142%2C%22cust_name%22%3A%22List+Price%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22last_modified_date%22%3A%22%22%2C%22co%22%3A%22no%22%2C%22last_modified_by%22%3A%22%22%2C%22details%22%3A%22no%22%2C%22customAggregates%22%3A%5B%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%2C%22blockId%22%3A%22B0%22%7D%2C%22rt%22%3A%2251%22%2C%22filters%22%3A%5B%7B%22pc%22%3A%22CUST_RECORDTYPE%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22List_Price_Rule_vod%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeUG%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeT2%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeT1%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%5D%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22colDt_c%22%2C%22value%22%3A%2200N90000007QeY2%22%7D%2C%7B%22param%22%3A%22colDt_e%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22colDt_q%22%2C%22value%22%3A%22custom%22%7D%2C%7B%22param%22%3A%22colDt_s%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22function%22%2C%22value%22%3A%22c%22%7D%2C%7B%22param%22%3A%22name_op%22%2C%22value%22%3A%22co%22%7D%5D%7D%2C%7B%22templateKey%22%3A%2201I900000018lXc%22%2C%22scope%22%3A%22organization%22%2C%22topn%22%3A0%2C%22c%22%3A%5B%22CUST_NAME%22%2C%2200N90000007QeUH%22%2C%2200N90000007QeT7%22%5D%2C%22last_modified_user_id%22%3A%22%22%2C%22breaks%22%3A%5B%5D%2C%22sideBySide%22%3Afalse%2C%22sortdir%22%3A%22up%22%2C%22colorRanges%22%3A%5B%5D%2C%22entity%22%3A%2201I900000018lXc%22%2C%22format%22%3A%22t%22%2C%22v%22%3A142%2C%22cust_name%22%3A%22STT+Price%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22last_modified_date%22%3A%22%22%2C%22co%22%3A%22no%22%2C%22last_modified_by%22%3A%22%22%2C%22details%22%3A%22no%22%2C%22customAggregates%22%3A%5B%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%2C%22blockId%22%3A%22B3%22%7D%2C%22rt%22%3A%2251%22%2C%22filters%22%3A%5B%7B%22pc%22%3A%2200N90000007QeT2%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeT1%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007JDQt%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeUG%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeY2%22%2C%22pn%22%3A%22ge%22%2C%22pv%22%3A%22TODAY%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%2200N90000007QeTC%22%2C%22pn%22%3A%22le%22%2C%22pv%22%3A%22TODAY%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%2C%7B%22pc%22%3A%22CUST_RECORDTYPE%22%2C%22pn%22%3A%22eq%22%2C%22pv%22%3A%22Discount_Rule_vod%22%2C%22pc2%22%3A%22%22%2C%22cc%22%3Afalse%7D%5D%2C%22reportParams%22%3A%5B%7B%22param%22%3A%22colDt_c%22%2C%22value%22%3A%2200N90000007QeY2%22%7D%2C%7B%22param%22%3A%22colDt_e%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22colDt_q%22%2C%22value%22%3A%22custom%22%7D%2C%7B%22param%22%3A%22colDt_s%22%2C%22value%22%3A%22%22%7D%2C%7B%22param%22%3A%22function%22%2C%22value%22%3A%22c%22%7D%2C%7B%22param%22%3A%22name_op%22%2C%22value%22%3A%22co%22%7D%5D%7D%5D%2C%22format%22%3A%22mb%22%2C%22created_by_user_id%22%3A%22005900000022hZg%22%2C%22charts%22%3A%5B%7B%22ctsize%22%3A18%2C%22bgdir%22%3A%222%22%2C%22l%22%3A%221%22%2C%22bg2%22%3A16777215%2C%22csize%22%3A3%2C%22bg1%22%3A16777215%2C%22tfg%22%3A0%2C%22ct%22%3A%22none%22%2C%22sal%22%3Atrue%2C%22chco%22%3Atrue%2C%22chsp%22%3Afalse%2C%22cfsize%22%3A12%2C%22cp%22%3A%22b%22%2C%22cheh%22%3Afalse%2C%22fg%22%3A0%2C%22chst%22%3Afalse%2C%22summaries%22%3A%5B%5D%2C%22chsv%22%3Afalse%2C%22Yman%22%3Afalse%7D%5D%2C%22v%22%3A142%2C%22last_modified_date%22%3A%2214%2F11%2F2013+9%3A49+AM%22%2C%22co%22%3A%22yes%22%2C%22customAggregates%22%3A%5B%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22List+Price+List+Price%22%2C%22DeveloperName%22%3A%22FORMULA1%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22STT+Disc%22%2C%22DeveloperName%22%3A%22FORMULA2%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22STT+Net%22%2C%22DeveloperName%22%3A%22FORMULA3%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22STT+Disc+Net+Price%22%2C%22DeveloperName%22%3A%22FORMULA4%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%22%2C%22DataType%22%3A%22N%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22Contract+Disc+Net+Price%22%2C%22DeveloperName%22%3A%22FORMULA5%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22IF%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%3C%3E0%5Cn%2C+B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%5Cn%2C+IF%28B1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%3C%3E0%5Cn%2C%28B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+B1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%29+%2F+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%3C%3E0%5Cn%2CB3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%3C%3E0%5Cn%2C+%28B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%29%2FB0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%5Cn%2C0%5Cn%29%29%29%29%22%2C%22DataType%22%3A%22P%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22Final+Discount%22%2C%22DeveloperName%22%3A%22FORMULA6%22%2C%22RowBreakContext%22%3A%2200N90000007QeT8%22%2C%22Scale%22%3A2%7D%2C%7B%22IsCrossBlock%22%3Atrue%2C%22CalculatedFormula%22%3A%22IF%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+%3C%3E+0%5Cn%2C+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-%28B1%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*+B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%5Cn%2C+IF%28B1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG+%3C%3E+0%5Cn%2CB1%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+%3C%3E+0%5Cn%2CB0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG+-+%28B3%23Pricing_Rule_vod__c.Discount_Override_vod__c%3AAVG+*B0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%29%5Cn%2CIF%28B3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG+%3C%3E+0%5Cn%2CB3%23Pricing_Rule_vod__c.Net_Price_vod__c%3AAVG%5Cn%2CB0%23Pricing_Rule_vod__c.List_Price_vod__c%3AAVG%5Cn%29%29%29%29%22%2C%22DataType%22%3A%22C%22%2C%22IsActive%22%3Atrue%2C%22MasterLabel%22%3A%22Final+Net%22%2C%22DeveloperName%22%3A%22FORMULA7%22%2C%22Scale%22%3A2%7D%5D%2C%22blkInfo%22%3A%7B%22blkjt%22%3A%22x%22%7D%2C%22rt%22%3A%2251%22%2C%22cust_owner%22%3A%2200D90000000ome4%22%7D&repId=00O90000004ewmO"; // You REALLY want async = true. // Otherwise, it'll block ALL execution waiting for server response. var async = true; var request = new XMLHttpRequest(); // Before we send anything, we first have to say what we will do when the // server responds. This seems backwards (say how we'll respond before we send // the request? huh?), but that's how Javascript works. // This function attached to the XMLHttpRequest "onload" property specifies how // the HTTP response will be handled. request.onload = function () { // Because of javascript's fabulous closure concept, the XMLHttpRequest "request" // object declared above is available in this function even though this function // executes long after the request is sent and long after this function is // instantiated. This fact is CRUCIAL to the workings of XHR in ordinary // applications. // You can get all kinds of information about the HTTP response. var status = request.status; // HTTP response status, e.g., 200 for "200 OK" var data = request.responseText; // Returned data, e.g., an HTML document. var x=window.open().document; x.open(); x.write(data); x.close(); } request.open(method, url, async); request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // Or... request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); // Or... whatever // Actually sends the request to the server. request.send(postData); }I can see what is going on, array is being created, SoQL query executing, value being stored. But there are some elements I am not sure of:
var idArray = {!GETRECORDIDS($ObjectType.Contract_Partner_vod__c)}; // if the field you want for report critiera isn't avail from the detail record (ie list button) then need to get
Unsure of the syntax I use here. I'm obviously to get ID's from an object to use in a query, I just need to know if I'm going to be formatting it correctly. I would ask our Java guys but I think this falls into the realm of Salesforce syntax.
records = result.getArray("records"); for (var i=0; i< records.length; i++) { var record = records[i]; contrId = record.Contract_vod__c.substring(0,15); }
Not sure what this piece of the code is aiming to do either. Is it truncating the 18 character ID? Because if so, I can probably kill this section of code off as I will be purely dealing with strings.
The rest seems relatively straightforward, it looks like I would have to duplicate the code to find my second field to parse. This person is obviously looking for his one custom field to parse to the report, as reflected by the search and result obtained.
Can anyone shed some light here to help me through?
Thanks.
Point 1:
The code there is for when you are using a list button. As I was using a Page Detail Button, I could just refer to the object ID directly.
Point 2
This was pulling the single result from my SoQL results. Vital to use the variable in my parsed URL. So execute SoQL query and write to array, use the FOR loop to get the result you are looking for. Using ALERT(variablename) in my code was vital for me actually seeing what was going on, so use that as a debug.
Once that was sorted, it was indeed a case of getting both variables needed via 2 SoQL queries and dumping into the appropriate place in the parsed URL. All I need now is some error handling for NULL and I'm done.
This works for parsing data from a page to a joined report, so if anybody needs to do this and what I've written isn't transparent, give me a shout.
All Answers
Point 1:
The code there is for when you are using a list button. As I was using a Page Detail Button, I could just refer to the object ID directly.
Point 2
This was pulling the single result from my SoQL results. Vital to use the variable in my parsed URL. So execute SoQL query and write to array, use the FOR loop to get the result you are looking for. Using ALERT(variablename) in my code was vital for me actually seeing what was going on, so use that as a debug.
Once that was sorted, it was indeed a case of getting both variables needed via 2 SoQL queries and dumping into the appropriate place in the parsed URL. All I need now is some error handling for NULL and I'm done.
This works for parsing data from a page to a joined report, so if anybody needs to do this and what I've written isn't transparent, give me a shout.
How are you passing that variable in this whole code and I need to call the report from a command link on VF Page. would be really very helpful if you add some points on that.
Thank You.
Nishant Singh
The variables, those are inserted into the huge amount of ridiculous code on line 40. The instructions give you a breakdown on where to find the relevant tools to deconstruct the joined report URL into JSON, which you can then pick through to insert your variables. It is literally a case of finding the part of the JSON which deals with the paramenter, quoting out of the string and adding in the variable.
A bit like:
"stringofJSONcodegoesonandon" + hereisvariable + "stringofJSONcodecontinues"
The issue I had was that I was trying to use an array to find the variable from the Contract object. I didn't need to. I simply referred to the field directly. Check the Best Answer text for that.
For completed purposes, this was my final code. You can see I've chopped a whole load out, no arrays, no SOQL needed. It's literally define variables, call upon jscript, a single validation message, huge amount of JSON, code that pops the report:
"stringofJSONcodegoesonandon" + hereisvariable + "stringofJSONcodecontinues"
Mine is just replacing the filter with the text-name of the variable, so clearly it isn't injecting the variable at all. It's just using my JSON string when the button is pressed..
Could you elaborate on this part? I'm unable to find the extension you referenced in the post which I'm assuming makes this easier. This scenario is the exact thing I'm trying to solve currently!
The value of the "rt" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.
when we look at the "rt" in the postData variable it does not have an ID, why ? the record type is given to me by the runReportJson in the developer tools when i load the report, and its ID is correct and reffers to 2 report type IDs I am using in my joined report.
Anyone faced this issue ?
Thanks