Hi
I am a beginner in the subject of Dynamics 365
I ask for your help to solve this problem.
I have a form, with two tables, header and detail.
I created a number sequence, so that it increases when creating a record, I attach code.
But, I have to make the sequence consume if I enter data in the form, otherwise the fields are empty,
record should not be saved nor should the sequence be consumed. That is, if I click New,
the sequence is automatically consumed when opening the form (example: USMF-000020)
but if I do not fill in anything in the fields, when closing and reopening,
it must be the same numerical sequence, that is, USMF -000020.
Este es mi código de secuencia numérica, que se encuentra en mi formulario.
public str ConsumirSecuencia(NumberSequenceCode _secuenceGroup)
{
str voucher;
NumberSeq Ns;
try
{
Ns = NumberSeq::newGetNumFromCode(_secuenceGroup, NumberSeqScopeFactory::createDefaultScope(),
true, true);
if (Ns == null)
{
throw Exception::Error;
}
voucher = Ns.num();
Ns.used();
}
catch (Exception::Error)
{
error("No se pudo generar la sencuencia");
}
return voucher;
}
Y al correr el formulario, tengo en el código a nivel de datasource, que se inicialice con la secuencia numérica
[DataSource] class APSalesHeader
{
/// <summary> ///
/// </summary>
public void initValue ()
{
APSalesHeader.APOrderId = element.ConsumirSecuencia ('TR');
súper();
}
Por favor su ayuda. Y de antemano muchas gracias.