Hi all, New to SuiteScript and figuring out the p...
# suitescript
j
Hi all, New to SuiteScript and figuring out the possibilities. I couldn't find an example script of below functionality As a Sales Rep I want to create a Project(job) from the Opportunity and copy the values from the Opportunity to the Project So that I don't have to fill in values twice What kind of script should I use for this functionality? And how can I use values from the Opportunity in the script that runs on the Project? Any help would be appreciated 🙂 Thanks! ]
b
which fields do you want to copy
j
Fields from the opportunity like: SalesRep / End User (custom body field)
b
its an exercise for you
there is no copy mechanism for dissimilar records
you need to identify each one
grab their ids, and code copying the value to your new record
j
Ok, so I how do I know on what Opportunity the Project is being created?
b
there should be a project field on your opportunity
j
Correct, but when I create the project from the Opportunity-view this is not yet filled
b
you would set that to the matching opportunity
basically create the project then modify the opportunity
j
So I already have an Opportunity and want to create a new project linked to the Opportunity. I think the article describes the other way around. From Project to Opportunity
b
linking is the same
you set the project field on the opportunity
depending on your preference, the field may be on a sublist, or it may be on a body
j
Ok, at what moment and with what kind of script?
b
different scripts are triggered at different times
when do you want this to occur
j
In the Opportunity - Edit
b
as in when someone clicks edit on an opportunity record
or when they save the opportunity record
seems too loose requirement wise, i doubt you want a new project for every time a opportunity is edited
j
Edit the opportunity and add new Project next to the Project field
b
that pretty much limits you to client script
j
Ok
b
create a client script, deploy it to your project record
j
Check
b
you will be using the pageInit entry point to default your field defaults
j
Ok
(Thanks for your help btw 🙂 )
b
you will need to use window.opener from the project record to access the fields on the opportunity record
using window.opener.require will allow you to use ss2 functions from the opportunity record
j
Aha, so use JS to get the values from the Opportunity
b
yes
j
use JS to go to the Opportunity record and then I can use SS2 to get the values from the Opp record
âś… 1
SS2 = SuiteScript 2 ?
b
yes
j
Thanks a lot! I will try to figure this out and get back here
I can confirm that it works! Many thank @battk Within the create Project client script I added this line to get the SalesRep value from the Opportunity var salesRep = window.opener.nlapiGetFieldValue("salesrep");
âś… 1