Delivery log refers to an URL index=0

thibaultb473199

19-06-2019

Hello everyone,

I want to put some privacy typology rules in my deliveries so the customer can take a look at the policy rules on the website.

When looking into the delivery log, I notice that error :

nlclient_roPnW7fT8I.png

The warning mention that my privacy URL is missing and say that the +index=0, not like all the other links that send an +index=-1

I check in both template I'm using and the JS that manage  my privacy URL and the URL are both the same.

What can go wrong with that issue ? Where can I look to put that index to be equal to -1 like the other ? (I guess the issue must be coming from that)

Thank you in advance !

Kind regards.

Accepted Solutions (1)

Accepted Solutions (1)

ramon_bisswange

Employee

19-06-2019

Your code will check both text and HTML version.

So to succeed, in the log you would need to have "urlcheckreturntrue" being shown twice.

So I guess the link is not in the text version

Answers (3)

Answers (3)

wodnicki

MVP

19-06-2019

You want the index to be 0 here, it's literally index as in 'index of the url being searched for, in the url string', where 0 is position 0 and -1 is not found; that debug message is displaying all test output, and displaying the result as though it were part of the url.

thibaultb473199

19-06-2019

Hello Wodnicki, here is the code of my topology rule.

var exceptionBUList = ["WTCRU","WTCUA" ,"WTCTR" , "SRU"];

var sg = new StringGroup("nms:core");

var debug = 1;

//-------------------------------------------------------------------

// Constructor

//-------------------------------------------------------------------

function aswPrivacyURLPolicy(){

}

//-------------------------------------------------------------------

// Return the Privacy URL for the BU to which delivery belongs to

// @return : privacy URL for a BU

//-------------------------------------------------------------------

aswPrivacyURLPolicy.prototype.getURL = function(deliveryId) {

     var query = xtk.queryDef.create(

      <queryDef schema="nms:delivery" operation="get">

        <select>

          <node expr="[operation/@bu_Code]" alias="@buCode"/>

          <node expr="@Lang_id" alias="@langId"/>

        </select>

        <where>

          <condition expr={"@id = " + deliveryId}/>

        </where>

      </queryDef>

    );

   

  var res =  query.ExecuteQuery();

  this.buCode = res.@buCode.toString();

  this.langId=res.@langId.toString(); 

  var privacyURL = "";

    

  switch (this.buCode){

      case "KVF":

        privacyURL = "https://www.kruidvat.fr/confidentialite";

        break;

      case "KVB":

        {

          if (this.langId === "NLD")

            privacyURL = "https://www.kruidvat.be/nl/privacybeleid";

          if (this.langId === "FRB")

            privacyURL = "https://www.kruidvat.be/fr/politiquedeconfidentialite"

        };

        break;

      case "KVN":

        privacyURL = "https://www.kruidvat.nl/privacybeleid";

        break; 

     default:

    privacyURL = "";

} //End - switch (this.buCode)

if (debug) logInfo('URL:#' + privacyURL + '#');

this.privacyURL=privacyURL; 

query = null;

res = null;  

}

//-------------------------------------------------------------------

// Check if BU is part of exception list for which GDPR is not mandatory

// @return : true if BU belongs to exception list

//-------------------------------------------------------------------

aswPrivacyURLPolicy.prototype.ifExceptionBU = function() {

  

   var exception = false;

   for (index = 0; index < exceptionBUList.length; index++) {

      if (this.buCode ===  exceptionBUList[index]){

          exception = true;

          return exception;

      }//End - (this.buCode ===  exceptionBUList[index])

  }//End - for      

  if (debug) logInfo("Is Exception BU = " + exception);

  return exception;

}

//-------------------------------------------------------------------

// Check for the presence of privacy URL in the URL list

// @return message:

// true -  found

// false - Not found

//-------------------------------------------------------------------

aswPrivacyURLPolicy.prototype.checkUrlSource = function(urlList, strContent, privURL)

{

    for( var i=0 ; i<urlList.length ; i++ ){

      if( urlList[i].trackingType != 1 && urlList[i].trackingType != 3 ){

        // check an URL

        var url = urlList[i].source;

        if (debug) logInfo('FOUNDURL: '+url+'+index='+url.indexOf(privURL));

        if( url.indexOf(privURL) > -1 ){

        if (debug) logInfo('urlcheckreturntrue');

          return true;

        }//End - if( url.indexOf(privURL) > -1 )

      } //End-if( urlList[i].trackingType != 1 && urlList[i].trackingType != 3 )

    }//End - for

  return false;

}

//-------------------------------------------------------------------

// Audit a delivery to check for inclusion of privacy URL

// @return message:

// Empty String -  Success

// message- Error or Warning

//-------------------------------------------------------------------

aswPrivacyURLPolicy.prototype.auditDelivery = function(deliveryId) {

if (debug) logInfo("Applying Typlogy rule aswPrivacyURLPolicy");

this.getURL(deliveryId);

var message = "Typology aswPrivacyLinkValidation: Missing Privacy URL:" + this.privacyURL + " for BU:"+ this.buCode + " and Language:" + this.langId;

//Set default log level to warning for BU's in exception list else set default to Error

 

if(this.privacyURL.length == 0){

  return message;

}

if(delivery.deliveryMode ==0){

   message = "";

   return message;

}

var sourceHTML = delivery.content.html.source;

var sourceText = delivery.content.text.source;

//logInfo("sourceHTML = " + sourceHTML);

var bSucessText = false;

var bSucessHtml = false;

 

if( !delivery.tracking.enabled ){

    // nothing to do if tracking is disabled

    bSucessText = null;

    bSucessText = null;

    message = "";

    return message;

}

 

var bSucessText = this.checkUrlSource(delivery.content.text.urlConfig.url, "TEXT", this.privacyURL);

var bSucessHtml = this.checkUrlSource(delivery.content.html.urlConfig.url, "HTML", this.privacyURL);

 

if( bSucessText && bSucessHtml ){

    if (debug) logInfo('Success! Returning Success');

    bSucessText = null;

    bSucessText = null;

    message = "";

    return message;

}

if (debug) logInfo('Failure! Returning Error Message');

return message;

}