Last active
August 29, 2015 14:14
-
-
Save arufian/197fc5ae7a1014fe61bb to your computer and use it in GitHub Desktop.
Revisions
-
arufian revised this gist
Jan 26, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // refs: http://www.jitendrazaa.com/blog/salesforce/salesforce-rest-api-playground/ function getQueryStringValue (key) { return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1")); } -
arufian created this gist
Jan 26, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ function getQueryStringValue (key) { return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1")); } {!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")}; var records = {!GETRECORDIDS($ObjectType.Book__c)}; var counter = 0; for(var i=0; i<records.length; i++){ var xmlhttp = new XMLHttpRequest(); xmlhttp .onload = function(e) { counter++; if(counter === records.length) { var fcf = getQueryStringValue('fcf'); var winlocation = window.location; window.open(winlocation.pathname + '/x?fcf='+fcf); } } xmlhttp.open("PATCH", '/services/data/v29.0/sobjects/Book__c/'+records[i], true); xmlhttp.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); xmlhttp.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}'); xmlhttp.send(JSON.stringify({IsPrinted__c:"true"})); } </script> </apex:page>