function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eva DeLoriolEva DeLoriol 

How to add the Data.com Clean button on Visualforce Pages

Can we add the Data.com Clean button to Visual force pages? It appears to require a csrf token.I am trying to deconstuct the standard button but maybe someone has already come up with a way to add the Data.com Clean button to a Visual force page.

I have written some code that gets the confirmationtoken and tries to insert it into the csrf arg, but I am still not getting anything other than the error about an invalid session. 

JavaScript to get the key:
<script>
 // get confirmation token and set webform field
 var jQuery = jQuery.noConflict();
 jQuery(function($){
  $(document).ready(function(){
$.ajax({
url:location.href,
contentType:"text/html",
xhrFields:{withCredentials:true}
}).done (
function(data){
key_start='chatter.getToolbox().setToken(';
key_end=');';
pos_start=data.indexOf(key_start);
pos_end=data.indexOf(key_end,pos_start+key_start.length);
confirmationtoken=data.substring((pos_start+key_start.length)+1,pos_end-1);
//add value to page params 
console.log('^^^^^^^^^^^^^^^^^^^^^^ confirmationtoken val : ' + confirmationtoken);
paraConfirm(confirmationtoken);
});
});	
 });

function stopPage(){
return false;
}	
 </script>

Actionfunction to use the key:
 
<apex:actionFunction name="paraConfirm" rerender="buttonform" onComplete="stopPage();">     
     <apex:param id="ct" name="confirmationtoken" value="" />
 </apex:actionFunction>

Button for "Clean"
<input value=" Clean " id="dataClean" class="btn" title="Clean" 
name="datadotcomclean" type="button" onclick="SfdcApp.DataDotCom.CleanDialog.showDialog({entityId:'{!LEFT(account.id,15)}',cleanStatus:'1',csrf:'{!csrfValue}'})"/>

The csrfValue is coming from the Controller where I am just returning what was passed via the JavaScript:
public String getCsrfValue(){
    csrfValue = Apexpages.currentPage().getParameters().get('confirmationtoken');

    Apexpages.currentPage().getParameters().put('csrf', csrfValue);
	return csrfValue;
		
	}

I know that the value is being passed to the controller since I had debug statements there to let me know if it was successful or not.

If anyone has actually figured this out I would really appreciate the help. 

Maybe it isn't the confirmationtoken that I need to use, but when viewing a standard page, it looks similar since they start with a "VF..."
Thanks!