Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

How don't save a register if the fields are empty

(0) ShareShare
ReportReport
Posted on by 5
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.

















  • LuHao Profile Picture
    40,886 on at
    RE: How don't save a register if the fields are empty

    Hi carmen,

    Can you tell me which D365 app you are using?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,467 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans