Passa al contenuto principale
Adaptive Planning
Ultimo aggiornamento: 2025-11-21
ai.util

ai.util

Funzioni

Metodo
Parametri
Resi
Descrizione
apply( obj, config )
  • obj: Object Il destinatario delle proprietà
  • config: Object L'origine delle proprietà
Oggetto
Copia tutte le proprietà di config in obj e restituisce obj.
decodeBase64( encodedBase64 )
disponibile nel 2018.3
  • encodedBase64: String
Una stringa codificata come Base64. E.g. dGV4dA==
String
Restituisce una stringa Base64 decodificata.
Testo
decodeHtml( encodedHtml )
disponibile nel 2018.3
  • encodedHtml: String
Una stringa con caratteri riservati convertiti da utilizzare nei valori letterali HTML. Salve <b> [there] >words<!
String
Restituisce una stringa in formato HTML non elaborato.
'Ciao <b> [there] >words<!'
decodeUrl( encodedUrl )
disponibile nel 2018.3
  • encodedUrl: String
Una stringa con un URL con codifica HTML. Ad esempio https%3a%2f%2fwww.example.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash
String
Restituisce una stringa con un URL non elaborato.
https://www.example.com/fings/?id=123&more=words#hash
decrypt(cryptText)
  • cryptText: la stringa crittografata generata in precedenza dalla funzione ai.util.encrypt() .
String
Restituisce la stringa di testo normale decrittografata originale.
La funzione ai.util.decrypt() inverte il processo di crittografia, prelevando una stringa crittografata (in genere una password o una chiave API memorizzata) e riconvertendola nel formato di testo normale originale in modo che possa essere utilizzata all'interno dello script origine dati cloud personalizzata per l'autenticazione rispetto a un sistema esterno o API.
Per configurare questo metodo, configurare prima la crittografia Pretty Good Privacy (PGP). ConsultareConfigurare la crittografia PGP .
encodeBase64( rawBase64 )
disponibile nel 2018.3
  • rawBase64: stringa
Una stringa con testo. Ad es Testo
String
Codifica il testo come Base64.
dGV4dA==
encodeHtml( rawHtml )
disponibile nel 2018.3
  • rawHtml: stringa
Una stringa con codice HTML non elaborato. Ad es 'Ciao <b> [there] >words<!'
String
Restituisce una stringa con caratteri riservati convertiti da utilizzare nei valori letterali HTML.
Salve &lt;b&gt; [there] &gt;words&lt;!
encodeUrl( rawUrl )
disponibile nel 2018.3
  • rawUrl: String
Una stringa con un URL non elaborato. Ad es. https://www.example.com/fings/?id=123&more=words#hash
String
Restituisce un URL non elaborato come HTML codificato.
https%3a%2f%2fwww.example.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash
encrypt( textToEncrypt )
  • textToEncrypt: il valore di testo normale che si desidera crittografare in modo sicuro. Si tratta in genere di una password o di informazioni riservate utilizzate in una chiamata API successiva.
String
Restituisce la rappresentazione crittografata della stringa di input. Questo output deve essere utilizzato per archiviare o trasmettere credenziali riservate anziché il testo normale.
La funzione ai.util.encrypt() applica un algoritmo di crittografia (gestito dalla piattaforma Workday Adaptive Planning ) alla stringa di testo normale fornita. Viene utilizzato principalmente negli script Custom Cloud Data Source (origine dati cloud personalizzata) per proteggere le credenziali prima di archiviarle come parametri di configurazione nella configurazione integrazione .
Per configurare questo metodo, configurare prima la crittografia Pretty Good Privacy (PGP). ConsultareConfigurare la crittografia PGP .
format ( formatString, arg1, arg2....argN )
  • formatString: String Una stringa con token di sostituzione. Ad es. "Ci sono {0} elementi"
  • arg1: String Il valore da sostituire il token {0}
  • arg2: String ecc...
String
Utilizzato per definire una stringa in token e passare un numero arbitrario di argomenti per sostituire i token. Ogni token deve essere univoco e deve essere incrementato nel formato {0}, {1} e così via.
isDate( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato è un oggetto Data JavaScript.
isUndefined( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato è "undefined".
isDefined( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato non è "undefined".
isArray( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato è una matrice JavaScript, in caso contrario false.
isString( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato è una stringa.
isNumber( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato è un numero ed è finito.
isBoolean( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce vero se il valore passato è vero o falso.
toArray( a, i, j )
Matrice
isPrimitive( value )
  • value: Mixed Il valore da verificare
Booleano
Restituisce true se il valore passato è una stringa, un numero o un valore booleano.

Esempi

//Example for ai.util.apply var sourceObj = {department:"Engineering"}; var destObj={}; ai.util.apply(destObj,sourceObj); ai.log.logInfo("Source Properties applied to Destination object: "+JSON.stringify(destObj)); // Source Properties applied to destination object: {department:Engineering} //Example for ai.util.decodeHtml var encodedHtml = "Hello &lt;b&gt; [there] &gt;words&lt;!"; var decodedvalue=ai.util.decodeHtml(encodedHtml); ai.log.logInfo("Decoded HTML is " +decodedvalue); // Decoded HTML is Hello [there] >words //Example for ai.util.encodeHtml var rawHtml = "Hello <b> [there] >words<!"; var encodedvalue=ai.util.encodeHtml(rawHtml); ai.log.logInfo("Encoded HTML is " +encodedvalue); // Encoded HTML is Hello <b> [there] >words<! //Example for ai.util.decodeBase64 var encodedBase64 = "VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGZvciBlbmNvZGluZw=="; var decodedbasevalue= ai.util.decodeBase64(encodedBase64); ai.log.logInfo("Decoded base64 is: "+decodedbasevalue); //Decoded base64 is:"This is a sample text for encoding" //Example for ai.util.encodeBase64 var rawBase64 = "This is a sample text for encoding"; var encodedbasevalue= ai.util.encodeBase64(rawBase64, ""); ai.log.logInfo("Encoded base64 is: "+encodedbasevalue); //Encoded base64 is:VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGZvciBlbmNvZGluZw== //Example for ai.util.encodeUrl var rawUrl = "https://docs.postman-echo.com/"; var encodedUrl=ai.util.encodeUrl(rawUrl); ai.log.logInfo("Encoded URL is: "+encodedUrl); //Encoded URL is: https%3a%2f%2fdocs.postman-echo.com%2f //Example for ai.util.decodeUrl var encodedUrl = "https%3a%2f%2fdocs.postman-echo.com%2f"; var decodedUrl=ai.util.decodeUrl(encodedUrl); ai.log.logInfo("Decoded URL is: "+decodedUrl); //Decoded URL is: https://docs.postman-echo.com/ //Example for ai.util.encrypt function testConnection(context) { var message = "-----BEGIN PGP MESSAGE-----" +"Version: GnuPG v2.0.14 (GNU/Linux)" +"Your Message" +"-----END PGP MESSAGE-----"; var text = ai.util.decrypt(message,'myPgp'); ai.log.logInfo("text message", text); return true; } //Example for ai.util.decrypt function testConnection(context) { var text = "Text to encrypt"; var encrypedPgpMessage = ai.util.encrypt(text,'myPgp'); ai.log.logInfo("encrypted message", encrypedPgpMessage ); return true; } //Example for ai.util.format var formatted=ai.util.format('How ar{0} you{1}',"e","?"); ai.log.logInfo("Formatted String is: "+formatted); //How are you? //Example for ai.util.isDate() var d = new Date(); var verifyIfDate=ai.util.isDate(d); ai.log.logInfo("Provided value is: "+verifyIfDate); //Provided value is: true //Example for ai.util.isUndefined var sampleValue; var verifyIfUndefined=ai.util.isUndefined(sampleValue); if (verifyIfUndefined) { ai.log.logInfo("Value is undefined"); } else { ai.log.logInfo("Value is defined"); } //Value is undefined //Example for ai.util.isDefined var sampleValue=6; var verifyIfDefined=ai.util.isDefined(sampleValue); ai.log.logInfo("verifyIfDefined: "+verifyIfDefined) if (verifyIfDefined) { ai.log.logInfo("Value is defined"); } else { ai.log.logInfo("Value is undefined"); } //Value is defined //Example for ai.util.isArray var sampleValue=["a","b"]; var verifyIfArray=ai.util.isArray(sampleValue); if (verifyIfArray) { ai.log.logInfo("Is is an Array"); } else { ai.log.logInfo("Not an Array"); } //It is an array //Example for ai.util.isString var sampleValue="123"; var verifyIfString=ai.util.isString(sampleValue); if (verifyIfString) { ai.log.logInfo("Is is a string"); } else { ai.log.logInfo("Not a string"); } //Example for ai.util.isNumber var sampleValue = {firstName:"Jon", lastName:"Doe"}; var verifyIfNumber=ai.util.isNumber(sampleValue); if (verifyIfNumber) { ai.log.logInfo("Is is a number"); } else { ai.log.logInfo("Not a number. Provided value is of type: "+typeof(sampleValue)); } //Not a number. Provided value is of type: object //Example for ai.util.isBoolean var sampleValue = true; var verifyIfBoolean=ai.util.isBoolean(sampleValue); if (verifyIfBoolean) { ai.log.logInfo("Value is Boolean"); } else { ai.log.logInfo("Not a Boolean. Provided value is of type: "+typeof(sampleValue)); } //Value is Boolean //Example for ai.util.isPrimitive var sampleValue = {firstName:"Jon", lastName:"Doe"}; var verifyIfPrimitive=ai.util.isPrimitive(sampleValue); if (verifyIfPrimitive) { ai.log.logInfo("Provided value is a Primitive Data Type"); } else { ai.log.logInfo("Provided value is not primitive: "+typeof(sampleValue)); } return true;