Hello, i'm trying to update our data center-specif...
# suitescript
h
Hello, i'm trying to update our data center-specific domains to account-specific urls for external forms. I set this script parameter to be "https://{123456}.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=16&deploy=1&compid=123456&h=4e7fc4ae254bb12779addd". However, when i run the Post request, it still returns this url: "https://forms.na3.netsuite.com/app/site/hosting/scriptlet.nl?script=16&deploy=1&compid=123456&h=4e7fc4ae254bb12779addd". Could someone help please?
b
Share the code
h
Copy code
if ( request.getMethod() == 'POST' ){
			
    var getRequestXML = nlapiStringToXML(getRequest);
    
    if (getRequestXML != null){
    
        var sharedsecretFromXML = nlapiSelectValue(getRequestXML, '//SharedSecret');
        var sharedsecret = nlapiGetContext().getSetting('SCRIPT', 'custscript_punchout_shared_secret');		
        var buyerCookie = nlapiSelectValue(getRequestXML, '//BuyerCookie');
        var webstoreURL = nlapiGetContext().getSetting('SCRIPT', 'custscript_punchout_webstore_url');    // to get the parameter "Punchout Webstore Url"
        nlapiLogExecution('debug', 'webstoreURL', webstoreURL);
        // <https://forms.na3.netsuite.com/app/site/hosting/scriptlet.nl?script=16&deploy=1&compid=123456&h=4e7fc4ae254bb12779addd>
        // SHOULD BE: <https://123456.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=16&deploy=1&compid=123456&h=4e7fc4ae254bb12779ad>
        var punchoutURL = nlapiSelectValue(getRequestXML, '//BrowserFormPost/URL');
        nlapiLogExecution('debug', 'punchoutURL', punchoutURL);     
        
        if (sharedsecretFromXML == sharedsecret){                       
            if (buyerCookie != null){
                webstoreURL = nlapiEscapeXML(webstoreURL + '&session=' + buyerCookie);
                nlapiLogExecution('debug', 'webstoreURL with cookie', webstoreURL);   
                //<https://forms.na3.netsuite.com/app/site/hosting/scriptlet.nl?script=16&deploy=1&compid=123456&h=4e7fc4ae254bb12779ad&session=PSFT_20200519165344000222>
                
               
                xml = string_replace(getFileContents, '<URL>', '<URL>' + webstoreURL);
                
                var cXMLArray = getRequestXML.getElementsByTagName("cXML");				
                
                if (cXMLArray != null){
                    var version = cXMLArray.item(0).getAttribute("version");
                    var timestamp = cXMLArray.item(0).getAttribute("timestamp");
                    var payloadID = cXMLArray.item(0).getAttribute("payloadID");
                    
                    if(version != null){
                        xml = string_replace(xml, 'version=""', 'version="' + version +'"');
                    }
                    
                    
                    if(timestamp != null){
                        xml = string_replace(xml, 'timestamp=""', 'timestamp="' + timestamp +'"');
                    }
                    
                    
                    
                    if(payloadID != null){
                        xml = string_replace(xml, 'payloadID=""', 'payloadID="' + payloadID +'"');
                    }
                    
                    
                }
                
                var filters = new Array();
                filters[0] = new nlobjSearchFilter( 'custrecord_punchout_session', null, 'is', buyerCookie);
                
                var searchresults = nlapiSearchRecord( 'customrecord_punchout_session_url', null, filters, null);
                
                
                for ( var i = 0; searchresults != null && i < searchresults.length; i++ )	{	
                    // get result values	
                    var searchresult = searchresults[ i ];	
                    var record = searchresult.getId( );	
                    var rectype = searchresult.getRecordType( );	
                    
                    nlapiDeleteRecord(rectype, record);
                    
                    
                }
                
                
                
                var session_url_record = nlapiCreateRecord( 'customrecord_punchout_session_url');
                session_url_record.setFieldValue( 'custrecord_punchout_session', buyerCookie);
                session_url_record.setFieldValue( 'custrecord_punchout_session_url', punchoutURL);
                
                var id = nlapiSubmitRecord(session_url_record, true);	

                

                
                
                
                

            }else{
            
                '<message>'+

                       'buyerCookie is not specified. Please resubmit.'+

                '</message>';

            
            }
            
            
            

            
            
        }else{
        
        

            xml =   '<?xml version="1.0" encoding="utf-8" ?>'+

                    '<message>'+

                       'Shared Secret is incorrect. Please resubmit.'+

                    '</message>';
        
        
        }
    
    }else{
    
    
    
    
        xml =   '<?xml version="1.0" encoding="utf-8" ?>'+

                    '<message>'+

                       'Request is not formed correctly. Please resubmit.'+

                    '</message>';
    
    
    
    }
b
What does the script deployments parameters look like
h
b
i mostly want to see if the id of your script parameters are correct
h
oh the param id is: custscript_punchout_webstore_url
b
unless you are entering the parameter wrong somewhere, your code looks okay
you may simply want to bypass the issue and use nlapiResolveURL to generate the url
h
so are you saying i should use nlapiResolveURL for "webstoreURL" instead of nlapiGetContext().getSetting()?
sorry i inherited this script from another developer and i'm not familiar with 1.0
b
i personally would have used nlapiResolveURL, which can generate the external url
you can share screenshots of the parameters on the script page, and the parameters on the script deployment if you want additional help on the parameter
h
message has been deleted
message has been deleted
b
your parameter is company level
you set it in the General Preferences
h
sorry which level should the param be?
b
company level preferences are set in the General Preferences
user level preferences are set in the user's preferences
the default empty value is set in the script deployment's parameters
your script parameter's preference level is set to company, so its value should be set in the general preferences of the company
h
oh geez, i found it
thanks so much !!! you're a life saver
s
his screenname is @battk but he's really BatMan.
h
haha i believe he is