Hopefully this is an easy question, How do i get t...
# suitescript
p
Hopefully this is an easy question, How do i get the internal ID of the record i am creating in an aftersubmit event?
j
Do you mean a record you are creating in the script? like
Copy code
record.save()
. If that is the case store it in a variable
Copy code
var newRec = record.save()
That will store the id as the save method returns the id
👍 1
p
No, the script is not creating the record, the record is getting created in UI. The script is a 1.0 userevent script with aftersubmit event
r
context.newRecord.id
?
var new_case = record.load({type: record.Type.SUPPORT_CASE, id: context.newRecord.id});
sorry, you said 1.0
j
Copy code
nlapiGetNewRecord()
nlapiGetOldRecord()
nlapiGetRecordId()
One of these I believe, but I don't work in 1.0 that much and only read about that API when necesssary.
k
nlapiGetRecordType(), nlapiGetRecordId()
use these two APIs after submit function
👍 1
function afterSubmit() { var loadrec = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); }
p
Thanks a lot for the reply guys, let me check & get back to you.
k
make sure to use nlapiLogExecution(‘DEBUG’, ‘Load New Rec’, loadrec);
p
Thanks a lot, nlapiGetRecordId() worked but the mistake was after that where i was using rec.getFieldValue instead of nlapiGetFieldValue(). but now it's leading to a different issue where after submit everything processes & it goes to a blank page. https://system.na2.netsuite.com/app/common/custom/custrecordentry.nl
The record does get created but it wont load that page back
@Kevin , @reptar any suggestions ?
k
show your code
did you use nlapiSubmitRecord();
p
function scheduled(type, form, request) { nlapiLogExecution('DEBUG', 'AfterSubmit', type); if(type!='delete'){ var internalId = nlapiGetRecordId(); nlapiLogExecution('DEBUG', 'AfterSubmit', nlapiGetRecordId()); var Vinrec= nlapiGetFieldValue('custrecord_tam_ad_vi_vin'); var InsType=nlapiGetFieldValue('custrecord_tam_ad_vi_insurance_type'); var InsExp=nlapiGetFieldValue('custrecord_tam_ad_vi_policy_end_date'); var inscompany=nlapiGetFieldValue('custrecord_tam_ad_vi_full_cov_ins_co'); var vehrecord=nlapiLoadRecord('customrecord_advs_vm',Vinrec); var FCExpVM=vehrecord.getFieldValue('custrecordfullci_exp'); var LIExpVM=vehrecord.getFieldValue('custrecord1038'); var nowInsExp = new Date(InsExp); var nowFCExpVM= new Date(FCExpVM); var nowLIExpVM= new Date(LIExpVM); nlapiLogExecution('DEBUG', 'VIN', Vinrec); nlapiLogExecution('DEBUG', 'INS TYPE', InsType); nlapiLogExecution('DEBUG', 'INS END DATE', nowInsExp); if(InsType==1){ nlapiLogExecution('DEBUG', 'FCEXPVM', nowFCExpVM); if(FCExpVM=='' || FCExpVM==null || nowFCExpVM<nowInsExp){ nlapiLogExecution('DEBUG', 'InsExp', InsExp); nlapiSubmitField('customrecord_advs_vm',Vinrec,'custrecordfullci_exp',InsExp,false); nlapiSubmitField('customrecord_advs_vm',Vinrec,'custrecord_tam_ad_vm_fc_ins_co_name',inscompany,false);//vehrecord.setFieldValue('FCExpVM', InsExp) nlapiLogExecution('DEBUG', 'Ins Exp for Full Coverage', InsExp); } } if(InsType==2){ nlapiLogExecution('DEBUG', 'LIExpVM', LIExpVM); if(LIExpVM=='' || LIExpVM==null || nowLIExpVM<nowInsExp){ nlapiLogExecution('DEBUG', 'InsExp', InsExp); nlapiSubmitField('customrecord_advs_vm',Vinrec,'custrecord1038',InsExp,false); //vehrecord.setFieldValue('FCExpVM', InsExp) nlapiSubmitField('customrecord_advs_vm',Vinrec,'custrecord_tam_ad_vm_liab_ins_co_name',inscompany,false); nlapiLogExecution('DEBUG', 'Ins Exp for Liability', InsExp); } } } return true; }
r
probably need to handle server response
idk, i've only done that with a suitelet
p
should i use that even though i'm not loading that record ?
r
what type of script is it?
p
Userevent
can i use nlapiSubmitRecord() & let go of the return altogether ?
r
i'm just confused, why is that function called scheduled?
🤐 1
p
hahaha i forgot to change the name i
😛 there was a conflicting workflow that was causing this, thanks for all your help guys.