Hello, everyone. I'm trying to create a customer p...
# suitescript
a
Hello, everyone. I'm trying to create a customer payment from an invoice in a Suitelet using the
record.transform
module. However, I'm encountering issues with the date (
trandate
) of the payment. It seems to be attempting to use today's date, and the accounting period isn't open yet. I tried passing the value of December 31st to avoid this, but it's giving me an error with that value. Does anyone know why? Has anyone encountered this error before? the code is this: var defaultDate = new Date('12/31/2023'); var fecha = new Date(defaultDate); // Obtener los componentes de la fecha var dia = fecha.getUTCDate(); var mes = fecha.getUTCMonth() + 1; // Sumar 1 porque los meses en JavaScript son indexados desde 0 var anio = fecha.getUTCFullYear(); // Formatear la fecha al formato DD/MM/AAAA var fechaFormateada = (dia < 10 ? '0' : '') + dia + '/' + (mes < 10 ? '0' : '') + mes + '/' + anio; log.audit("fechaFormateada", fechaFormateada); log.audit("formattedDate", defaultDate); var objRecord3 = record.transform({ fromType:'invoice', fromId: listId, toType: 'customerpayment', defaultValues: { trandate: fechaFormateada} });
m
trandate
is not one of the valid record initialization parameters you can use as a default value. You need to first initialize the transformed record, and then use record.setValue (for a Date) / record.setText (for a string) to set the date.
a
Sorry, you are right. I tried doing a set value before the save, and it worked correctly. Thank you very much.