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
Susanta ChakrabortySusanta Chakraborty 

The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator.

Hello

I need one quick help from you. Today I uninstalled the Sdoc app from our production and reinstall it for setting Sdoc number count 0 which I usually does in every end of FY. Everything got back except one problem. Whenever I generate field staff contract or anything through Sdoc template from any module getting the error msg.
"The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator."

As for example: There is one button called "Generate staff contract" in staff contract module page layout and its assign this code...
/apex/SDOC__SDCreate1?id={!Staff_Contract__c.Id}&Object=Staff_Contract__c


Also in Sdoc module I have enlisted the particular module in "related to type field" picklist. It usually works but now It doesn't.

Could you plss quickly let me know what went wrong and what will be the solution?
VinayVinay (Salesforce Developers) 
Hi Susanta,

Hope below links will help you.

https://help.salesforce.com/articleView?id=pages_creating.htm&type=5
https://releasenotes.docs.salesforce.com/en-us/spring17/release-notes/rn_vf_crsf_protection_cruc.htm?edition=&impact=
https://success.salesforce.com/answers?id=9063A000000e2NJQAY

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
SwethaSwetha (Salesforce Developers) 
HI Susanta,

Usually, when you Select "Require CSRF protection on GET requests" on a VF page, it gets enabled for GET requests made on the page. This functionality protects against CSRF attacks by modifying the page to require a CSRF confirmation token, a random string of characters in the URL parameters. All links to the VF page need a CSRF token added to the URL query string parameters. If it is missing, it throws the stated error.

However, based on the description , this appears to be an error at S-Docs side.You will need to contact the S-Docs support on the error you mentioned because the package code is not visible to others and also logs would not be generated to debug the issue.
 
Try reaching out to them via Support details mentioned on AppExchange Link: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000003HeuPEAS

For more information check
https://help.salesforce.com/articleView?id=000321516&type=1&mode=1

https://trailhead.salesforce.com/content/learn/modules/secdev_application_logic_vulnerabilities/secdev_app_logic_csrf

https://help.salesforce.com/articleView?id=pages_creating.htm&type=5

Please mark this answer as best so that this info would help others facing the same issue.

Thanks
Susanta ChakrabortySusanta Chakraborty
Sorry Vinay and Sweta still I can't get any understable solution from thiose links. We still using the classic version of SF, specially for developing basic struture.
I just uninstalled and reinstall the Sdoc app and from that time this error msg comes up. I can't find URLFOR function in button assign detail page.
Also how I can i get CSRF token as it shows in the error msg or the checkbox uncheck from the VF page.
Plss help me out. My organization suffering with some problems fro the reason.
SwethaSwetha (Salesforce Developers) 
HI Susanta,

Have you been able to check with the package provider on this? What is their take on it?

Please note that the  SDOC__SDCreate1 is an apex page that is part of managed package and we will not be able to view its code. 

Additional article: https://www.sdocs.com/resources/documentation/automation-options-improving-efficiency-and-compliance/

Thanks
Susanta ChakrabortySusanta Chakraborty
Hello guys for your better understanding I am maintioning one long code from VF page and its error msg while clicking on preview option
<apex:page controller="SDOC.SDCreateController" 
tabStyle="SDOC__SDTemplate__c" standardstylesheets="true"
sidebar="{!sidebar}"
action="{!initStep1}"
title="{!tm['Generate Documents']}"
lightningStylesheets="true">

<!-- ================ START LIGHTNING_REDIRECT_PANEL ================ -->
<apex:outputPanel id="lightning_redirect_panel">
<script>
if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
  if ('{!doLightningRedirect}' === 'true') {
    sforce.one.navigateToURL('{!lightningRedirectURL}', true);
  }
}
</script>
</apex:outputPanel>
<!-- ================= END LIGHTNING_REDIRECT_PANEL ================= -->

<!-- Must be included to use sforce.console.isInConsole() -->
<!-- Use version 30.0; isInConsole() doesn't work on version 40.0 -->
<apex:includeScript value="/support/console/30.0/integration.js"/>

<script type="text/javascript">
// Hide Salesforce header if showheader=false is included in URL
var hideHeader = function() {
  var salesforceHeader = document.getElementById('AppBodyHeader');
  if (salesforceHeader !== null) {
    salesforceHeader.style.display = 'none';
  }
}

var showHeader = '{!JSENCODE($CurrentPage.parameters.showHeader)}';
if (showHeader === 'false' || showHeader === '0') {
    hideHeader();
}
// End "Hide Salesforce header if showheader=false is included in URL"

// Hide Salesforce header if user is invoking S-Docs from Sales Console.
// This is finnicky as there are reported bugs with sforce.console.isInConsole();
// if this is the case, have the user include &showHeader=false in their S-Docs button. 
if (sforce.console.isInConsole()) {
    hideHeader();
}

var AgreementForm = document.getElementById("blur");
var ContainerElem = document.getElementById("StatusBox");
AlignToCenter(ContainerElem);
function AlignToCenter(Element)
{
var availableHeight = 0;
var availableWidth = 0;
if (Element.ownerDocument)
{
var docElement = Element.ownerDocument.documentElement;
availableHeight = parseInt(docElement.clientHeight);
if (availableHeight == "NaN") availableHeight = 0;

availableWidth = parseInt(docElement.clientWidth);
if (availableWidth == "NaN") availableWidth = 0;
}

if (availableHeight == 0 || availableHeight == "NaN")
availableHeight = window.screen.availHeight - 200;
if (availableWidth == 0 || availableWidth == "NaN")
availableWidth = window.screen.availWidth - 100;

var msgBoxTop = parseInt((availableHeight - parseInt(Element.clientHeight))/2);
var msgBoxleft = parseInt((availableWidth - parseInt(Element.style.width))/2);

if (msgBoxTop == "NaN" || msgBoxTop == 0)
msgBoxTop = 100;

Element.style.left = msgBoxleft + "px";
Element.style.top = msgBoxTop + window.pageYOffset + "px";
}

function reposition(){
if(navigator.appName == 'Window Internet Explorer') AgreementForm.style.top = document.body.scrollTop;
else AgreementForm.style.top = window.pageYOffset+"px";
//AlignToCenter(ContainerElem);
}
</script>
<apex:actionStatus id="statLoad">
    <apex:facet name="start">
        <div id="blur" style="position:absolute; left:1px; top:1px; width:100%; height:100%; text-align:center; vertical-align: middle; background-color: #dcdcdc; opacity:0.7;filter:alpha(opacity=70)">
        </div>
        <div id="StatusBox" style="position:absolute; left:50%; top:300px; width: 120px; height:50px; opacity:1;filter:alpha(opacity=100)">
        <table border="1" cellpadding="0" cellspacing="0" style="border-left-color: #336699;
        border-bottom-color: #336699; width: 120px; border-top-color: #336699; height:50px;
        border-right-color:#336699; background-color:#ffffff;">
        <tr>
        <td align="left" valign="top">
        <table border="0" cellpadding="4" cellspacing="0" style="width: 100%; height: 100%">
        <tr>
        <td style="border-bottom-color:#336699; border-bottom-width:0px; border-bottom-style:solid;vertical-align:middle;">
        <img src="{!URLFOR($Resource.SDoc,'spinner_large.gif')}"/></td>
        <td style="border-bottom-color:#336699; border-bottom-width:0px; border-bottom-style:solid;vertical-align:middle;color:darkred;font-size:11pt;font-weight:bold;">
        &nbsp;{!tm['Loading']}...</td>
        </tr>
        </table>
        </td>
        </tr>
        </table>
        </div>
    </apex:facet>
</apex:actionStatus>

<apex:sectionHeader title="{!tm['Create S-Docs']}" subtitle="{!tm['Generate Documents']}"/>
<apex:form >
<script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("{!$Component.searchText2}").value,
          document.getElementById("{!$Component.searchcategories}").options[document.getElementById("{!$Component.searchcategories}").selectedIndex].value
          );
      }
      </script> 

      <apex:actionFunction name="searchServer" action="{!initStep1}" rerender="panel3g" status="panel3gStatus">
          <apex:param name="txtValue" value=""/>
      </apex:actionFunction>  
      
<apex:pageMessages />
        <apex:outputPanel id="backnav" rendered="{!$User.UIThemeDisplayed !='Theme4t'}">
            <span class="style6">&lt;&lt;</span>
        <apex:commandLink action="{!returnToObj}" value="{!tm['Back']}"/> 
    </apex:outputPanel>
<br></br><br></br>
                <apex:panelGroup >
                     <apex:outputLabel for="searchcategories">{!tm['Search in']} &nbsp;</apex:outputLabel>
                     <apex:selectList id="searchcategories" size="1" value="{!docCategory}">
                        <apex:selectOptions value="{!docCategories}"/>
                        <apex:actionSupport event="onchange"  action="{!initStep1}" rerender="panel3g" status="panel3gStatus"/>
                    </apex:selectList>
                    <apex:outputLabel for="searchText2"> {!tm['for :']} &nbsp;</apex:outputLabel>
                        <apex:inputText id="searchText2" value="{!searchText2}" onkeyup="doSearch();"/>
                        <apex:commandButton value="{!tm['Search']}" action="{!initStep1}" rerender="panel3g" status="panel3gStatus">
                            <apex:param name="txtValue" value="{!searchText2}"/>
                        </apex:commandButton>
                    <apex:actionStatus id="panel3gStatus">
                        <apex:facet name="start">
                            <img src="{!URLFOR($Resource.SDoc,'spinner.gif')}" /> {!tm['Searching...']}
                        </apex:facet>
                    </apex:actionStatus>
                </apex:panelGroup>
                <br/>
                <br/>
                <apex:panelGroup rendered="{!JSENCODE($CurrentPage.parameters.AFPicklist) != 'false'}">
                    <apex:dataTable value="{!filterOptionsList}" var="filter">
                        <apex:column >
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'PICKLIST'}">
                                <apex:outputLabel for="filterCategoriesPicklist"> Filter on <b>{!filter.label}</b> for : &nbsp;</apex:outputLabel>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'MULTIPICKLIST'}">
                                <apex:outputLabel for="filterCategoriesMultiPicklist"> Filter on <b>{!filter.label}</b> for : &nbsp;</apex:outputLabel>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'BOOLEAN'}">
                                <apex:outputLabel for="filterCategoriesBool"> Filter on <b>{!filter.label}</b> for : &nbsp;</apex:outputLabel>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'STRING' || filter.fieldType == 'TEXTAREA'}">
                                <apex:outputLabel for="filterCategoriesString"> Filter on <b>{!filter.label}</b> for : &nbsp;</apex:outputLabel>
                            </apex:outputPanel>
                        </apex:column>
                        <apex:column >
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'PICKLIST'}">
                                <apex:selectList id="filterCategoriesPicklist" size="1" value="{!filter.filterOption}">
                                    <apex:selectOptions value="{!filter.possibleOptions}"/>
                                    <apex:actionSupport event="onchange"  action="{!initStep1}" 
                                    rerender="panel3g" status="panel3gStatus"/>
                                </apex:selectList>
                                <apex:actionStatus id="panel3gfilterPLStatus">
                                    <apex:facet name="start">
                                        <img src="{!URLFOR($Resource.SDoc,'spinner.gif')}" /> {!tm['Searching...']}
                                    </apex:facet>
                                </apex:actionStatus>
                            </apex:outputPanel>
                            <apex:outputPanel layout="block" rendered="{!filter.fieldType == 'MULTIPICKLIST'}">
                                <apex:selectList id="filterCategoriesMultipicklist" value="{!filter.filterOptionList}" multiselect="true" size="{!IF(filter.possibleOptions.size > 5, 5, filter.possibleOptions.size)}" style="width:130px;">
                                    <apex:selectOptions value="{!filter.possibleOptions}"/>
                                    <apex:actionSupport event="onchange"  action="{!initStep1}" 
                                    rerender="panel3g" status="panel3gStatus"/>
                                </apex:selectList>
                                <apex:actionStatus id="panel3gfilterMPLStatus">
                                    <apex:facet name="start">
                                        <img src="{!URLFOR($Resource.SDoc,'spinner.gif')}" /> {!tm['Searching...']}
                                    </apex:facet>
                                </apex:actionStatus>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'BOOLEAN'}">
                                <apex:selectList id="filterCategoriesBool" size="1" value="{!filter.filterOption}">
                                    <apex:selectOptions value="{!filter.possibleOptions}"/>
                                    <apex:actionSupport event="onchange"  action="{!initStep1}" 
                                    rerender="panel3g" status="panel3gStatus"/>
                                </apex:selectList>
                                <apex:actionStatus id="panel3gfilterBStatus">
                                    <apex:facet name="start">
                                        <img src="{!URLFOR($Resource.SDoc,'spinner.gif')}" /> {!tm['Searching...']}
                                    </apex:facet>
                                </apex:actionStatus>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!filter.fieldType == 'STRING' || filter.fieldType == 'TEXTAREA'}">
                                <apex:inputText id="filterCategoriesString" value="{!filter.filterOption}">
                                    <apex:actionSupport event="onkeyup"  action="{!initStep1}" 
                                    rerender="panel3g" status="panel3gStatus"/>
                                </apex:inputText>
                                <apex:actionStatus id="panel3gfilterSStatus">
                                    <apex:facet name="start">
                                        <img src="{!URLFOR($Resource.SDoc,'spinner.gif')}" /> {!tm['Searching...']}
                                    </apex:facet>
                                </apex:actionStatus>
                            </apex:outputPanel>
                        </apex:column>
                    </apex:dataTable>
                </apex:panelGroup>
<br></br><br></br>
<apex:pageBlock title="{!selectDocsClickNxtStep}">
<table width="100%">
<tr valign="top">
<td> 
    <apex:pageBlockSection columns="1" collapsible="false">
            <apex:pageBlockSectionItem >
                <apex:panelGroup id="panel3g">
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;
                         <img src="{!URLFOR($Resource.SDoc,'checkbox_arrow.png')}" />
                        <apex:commandButton action="{!step2}" value="{!btnTxtStep2}" styleClass="btn"
                          rendered="{!NOT(lightningNav)}" />
                        <apex:commandButton action="{!step2}" value="{!btnTxtStep2}" styleClass="btn"
                          rendered="{!lightningNav}" reRender="lightning_redirect_panel" />
                    </apex:outputText>
                    <apex:outputpanel style="overflow:scroll;height:250px;" layout="block">
                    <apex:pageBlockTable value="{!docsList}"  var="c" rendered="{!NOT(ISNULL(docsList))}">
                        <apex:column width="25px">
                            <apex:inputCheckbox value="{!c.checked}">
                            <apex:actionsupport event="onclick" action="{!addDoc}" rerender="panel4g" status="statLoad" />
                            </apex:inputCheckbox>
                        </apex:column>
                        <apex:column headerValue="{!tm['Name']}"><img src='{!c.formatIconImgSrc}' border='0' />
                        &nbsp;&nbsp;<apex:outputText value="{!c.t.Name}"/></apex:column>

                        <apex:column width="32px"> <!-- Container if e-vender value = s-sign -->
                        <apex:outputPanel rendered="{!c.t.SDOC__E_Sign_Vendor__c == 'SSIGN'}">
                            <b><img width="32" src="{!URLFOR($Resource.SDoc,'s-sign_logo.png')}" /></b>
                        </apex:outputPanel>
                        </apex:column>

                        <apex:column width="32px"> <!-- Container if allow edit value = true -->
                        <apex:outputPanel rendered="{!c.t.SDOC__Allow_Edit__c}">
                            <b><img src='/img/icon/custom51_100/pencil16.png' alt='Edit' border='0'/></b>
                        </apex:outputPanel>
                        </apex:column>

                        <apex:column value="{!c.t.SDOC__Description__c}" headerValue="{!tm['Description']}"/>

                        <apex:column value="{!c.t[additionalFields[0]]}" headerValue="{!additionalFieldsLabels[0]}" 
                        rendered="{!(numberOfAdditionalFields > 0)}"/>
                  <apex:column value="{!c.t[additionalFields[1]]}" headerValue="{!additionalFieldsLabels[1]}" 
                        rendered="{!(numberOfAdditionalFields > 1)}"/>
                        <apex:column value="{!c.t[additionalFields[2]]}" headerValue="{!additionalFieldsLabels[2]}" 
                        rendered="{!(numberOfAdditionalFields > 2)}"/>
                        <apex:column value="{!c.t[additionalFields[3]]}" headerValue="{!additionalFieldsLabels[3]}" 
                        rendered="{!(numberOfAdditionalFields > 3)}"/>
                        <apex:column value="{!c.t[additionalFields[4]]}" headerValue="{!additionalFieldsLabels[4]}" 
                        rendered="{!(numberOfAdditionalFields > 4)}"/>
                    </apex:pageBlockTable>
                    </apex:outputpanel> 
                    <apex:outputText rendered="{!recordCount>99}">
                        <b>[More Available - Use Search criteria to limit results]</b>
                    </apex:outputText>
                </apex:panelGroup>
            </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
</td><td></td>
<td>
    <apex:panelGroup id="panel4g">
        <apex:pageBlockSection title="{!tm['Selected Documents']}" columns="1" collapsible="false" rendered="{!hasSelectedDocs}">
             <apex:pageBlockSectionItem >
                    <apex:pageBlockTable value="{!selectedDocs}" var="ca" columnsWidth="50px, *" cellpadding="0" cellspacing="0">
                        <apex:column headerValue="{!tm['Remove']}">
                                <apex:commandLink value="X" action="{!removeDoc}" styleClass="btn" rerender="panel4g, panel3g" status="panel4Status">
                                    <apex:Param name="tid" value="{!ca.t.ID}" />
                                </apex:commandLink>
                        </apex:column>
                        <apex:column width="25px" headerValue="{!tm['Create Task']}">
                            <apex:inputCheckbox value="{!ca.taskCreate}" rendered="{!ca.t.SDOC__Task_Auto_Create__c}"
                                         disabled="{!ca.t.SDOC__Task_Auto_Create_Default__c=='Checked2'}">
                                    <apex:actionsupport event="onclick" action="{!addDoc}" rerender="panel4g, panel3g" status="panel4Status" />
                            </apex:inputCheckbox>
                            <apex:outputPanel rendered="{!ca.t.SDOC__Task_Auto_Create_Default__c=='Checked2'}">
                                <img src='/img/func_icons/util/lock12.gif'/>
                            </apex:outputPanel>
                        </apex:column>
                        <apex:column headerValue="{!tm['Name']}"><img src='{!ca.formatIconImgSrc}' border='0' />
                        &nbsp;&nbsp;<apex:outputText value="{!ca.t.Name}"/></apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:panelGroup>
    <apex:actionStatus id="panel4Status">
        <apex:facet name="start">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <img src="{!URLFOR($Resource.SDoc,'spinner.gif')}" /> {!tm['Updating...']}
        </apex:facet>
    </apex:actionStatus>    
</td>
</tr>
<tr>
    <td width="65%"></td>
    <td width="5%"></td>
    <td width="30%"></td>
</tr>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;
<apex:commandButton action="{!step2}" value="{!btnTxtStep2}" styleClass="btn"
  rendered="{!NOT(lightningNav)}" />
<apex:commandButton action="{!step2}" value="{!btnTxtStep2}" styleClass="btn"
  rendered="{!lightningNav}" reRender="lightning_redirect_panel" />
</apex:pageBlock>

</apex:form>
</apex:page>
Additionally mentioning the error msg which shows while click on preview option of the VF page
 
Attempt to de-reference a null object
Error is in expression '{!initStep1}' in component <apex:page> in page sdoc:sdcreate1: (SDOC)
 
An unexpected error has occurred. Your solution provider has been notified. (SDOC)
If this will help you to give the proper solution the plss do so.