what is record.copy? how do i use it, do i use on ...
# suitescript
r
what is record.copy? how do i use it, do i use on create record or when i save a record and make copy of it by clicking on the actions tab, how do i use it? i am very confused
1
c
What is your actual business requirement? (I saw your reddit post)
c
The docs seem pretty clear. You can use it in server or client side scripts, as long as the record you want to copy has actually been created. Excuse the conjecture, but i'm assuming you want to copy a record after it's created? Maybe? Using a userevent script, you'll only be able to use the afterSubmit entry point since this is the only one that triggers after the record has been submitted. All client script entry points are triggered before a record is submitted, so you're restricted to using a userevent script triggered by viewing the record, then injecting a client script to copy the record. If you just want to copy a record that has already been created in a seperate process, it's as simple as calling record.copy with the record type and id params.
Copy code
record.copy({
    type: record.Type.SALES_ORDER,
    id: 157
});
I've never used it before, but if you get any missing required field errors, setting the defaultValues parameter might fix that.
r
i dont know too,
TypeError: Cannot find function copy in object standard record.
i used rec.save on it too but nothing shows... the date logs, and everything .. i am attaching the code for a clearer statement
the new script and logs
b
there is a difference between N/record Module Members and Record Object Members
they are different objects with different member functions
r
thank you, my whole case worked out
@battk in the no shadow rule, am i not suppose to declare the variable in try( ), anyway it is going to catch if any error. I was not going to include any other function is it still not ok?
b
variable shadowing has more to do with what you name your variable over where you declare it