^^ anyone know of anything for the above. Really s...
# suitescript
k
^^ anyone know of anything for the above. Really struggling to find a AMD compatible module.
j
@karlenigma I've used a library for this in SS2, one sec I'll find which one
k
thank you so much.
I think i found one in NPM just trying to figure out how to install it.
a
There is a website where all NPM modules have the AMD version...
Let me try to find it...
k
thanks
j
I was mistaken, I've not used it in SS2, but did use it in SCA. In SS2 to generate a GUID I actually had a suitelet that made a credentials field and then got the value from that, maybe better to go the library route but the credentials field is always an option
Copy code
// Add a hidden credentials field 
    var credentialsField = form.addCredentialField({
      id: 'custpage_guid',
      label: 'GUID',
      restrictToDomains: '<http://www.netsuite.com/>',
      restrictToScriptIds: 'customscript_upload_file_test'
    });

    // Set the max length to be larger
    credentialsField.maxLength = '128';

    // Set field to be hidden
    credentialsField.updateDisplayType({
      displayType : serverWidget.FieldDisplayType.HIDDEN
    });
k
i'm building an integration and their API is complaining about the UUID i have created using
Copy code
function create_UUID(){
                var dt = new Date().getTime();
                return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                    var r = (dt + Math.random() * 16) % 16 | 0;
                    dt = Math.floor(dt / 16);
                    return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
                });
            }
Well i've got the npm UUID package now but no idea how i am supposed to import that into my suitelet.
just one .js file would be good.
any idea if this would work?
j
looks like you would just import this file from the github on to your suite script, have it in the define and then call as required? https://github.com/pnegri/uuid-js/blob/master/lib/uuid.js
k
then it would be UUID._create4
j
Yeah if you imported it as UUID then to get a v4 uuid would be var
uuid4 = UUID.create();
k
also put 4 in the params?
j
I copied that from the docs, never used it before. You'd need to give it a go but it seems supplying without params give you v4 by default
k
i'll give it a go.
a
@karlenigma This is the website https://unpkg.com/