1

I am trying to pass values entered in a textarea field on suitelet (new line/space/comma/pipe separated) from client script to suitelet. There is limitation of suiteleturl length. I am trying to pass those values as a array on values to suitelet url. In future user may enter more than 100 numbers in a textarea field. that may be problematic.

This is client script function to pass entered cdn numbers via parameters from client script to suitelet script.

function submitCDN() {
        var cdnInput = document.getElementById('custpage_enter_cdn').value;
   
    // Split the input string into an array, handling various separators
    var cidnArray = cdnInput.split(/[\n\s,\|]+/).filter(function(item) {
        return item.trim() !== ''; // Remove empty entries
    });

    // Construct the Suitelet URL with the CIDN array
    var suiteletUrl = url.resolveScript({
        scriptId: document.getElementById('script').value, // Assuming script id is on the form.
        deploymentId: document.getElementById('deploy').value, // Assuming deploy id is on the form.
        params: {}
    });

    // Append the CIDN array to the URL with square brackets
    suiteletUrl += '&cidn=' + cidnArray.map(encodeURIComponent).join('&cdn=');
    alert("suiteletUrl="+suiteletUrl);

    // Redirect to the Suitelet
    window.location.href = suiteletUrl;
}

Suitelet URL Log is, suiteletUrl=/app/site/hosting/scriptlet.nl?script=1234&deploy=1&compid=5678_SB&&cdn=11238734&cdn=74567654

2 Answers 2

1

An alternative approach would be to store those values in a custom record, then pass the internal ID of that custom record as a parameter to the Suitelet. Inside the Suitelet, you can use that internal ID to load the custom record and retrieve the stored values as needed. This keeps the URL clean and help manage larger data set more efficiently.

Sign up to request clarification or add additional context in comments.

Comments

0

Instead parsing like this, you can create a script parameter in suitelet, Either freeform text or long text based on your requirement and pass it like this

 var suiteletUrl = url.resolveScript({
        scriptId: document.getElementById('script').value, // Assuming script id is on the form.
        deploymentId: document.getElementById('deploy').value, // Assuming deploy id is on the form.
        params: {
scriptparamID: "Number"}
    });

Or else you can simply use different url parameter name like

app/site/hosting/scriptlet.nl?script=1234&deploy=1&compid=5678_SB&&cdn_1=11238734&cdn_2=74567654&cdn_3=74567654 

and mask the URL, so user can't see the cdn values in url.

1 Comment

If I add script parameter of longtext type. It may also have character limit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.