web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Validating in form extension without datasources

(0) ShareShare
ReportReport
Posted on by

Hello , I need to validate a create form without datasources.

Validating is based on 2 FormControls from EcoResProductCreate form.

1.  formControlStr(EcoResProductCreate, Types_ProductType)

2. formControlStr(EcoResProductCreate, SalesPrice)

For validating I take event handler in extension class but I dont know how to extract and interact with FormControls without datasources.

    [FormControlEventHandler(formControlStr(EcoResProductCreate, Types_ProductType), FormControlEventType::Validating)]
    public static void Types_ProductType_OnValidating(FormControl sender, FormControlEventArgs e)
    {
        FormControl fc = element.design().controlName(Types_ProductType);
        var args = e as FormControlEventArgs;
        boolean ret;

        ret = checkFailed('%1',fc.text());
        args.cancel(ret );
    }

    [FormControlEventHandler(formControlStr(EcoResProductCreate, SalesPrice), FormControlEventType::Validating)]
    public static void SalesPrice_OnValidating(FormControl sender, FormControlEventArgs e)
    {


    }

(I was trying some advice from web)

? How can I get Value from Form Controls and return checkFailed properly ?

I have the same question (0)
  • GirishS Profile Picture
    27,843 Moderator on at

    Hi dreed,

    For your scenario you can use COC instead of event handlers.

    Thanks,

    Girish S.

  • Community Member Profile Picture
    on at

    Thanks for answer , but what is coc? and how can I use it mate ? Im waiting for answers not advices bcs im newbie in d365.

  • GirishS Profile Picture
    27,843 Moderator on at
  • Community Member Profile Picture
    on at

    Maybe will be better if you will answer to my question without adding more confusion mate.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    I think you should hook into onValidated event, so that your code runs after the standard validation.

    You can check this example to understand how to set the return value of the validation (it's about a validateWrite event on a table, so there's some homework for you to apply it to your scenario): d365solution.blogspot.com/.../validatedwrite-eventhandler-d365-at.html

    I also warmly recommend Chain of Command if you want to avoid confusion, since it's much simpler and less confusing than events :)

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    I would also use COC but if you are going to do it with eventHandler you can try something like below. (This is a solution I haven't tried myself, I got it from the link below.)

    The situation in the link is slightly different but I hope the parmValidateResult will do the trick

    [FormControlEventHandler(formControlStr(EcoResProductCreate, Types_ProductType), FormControlEventType::Validating)]
    public static void Types_ProductType_OnValidating(FormControl sender, FormControlEventArgs e)
    {
        FormControl fc = element.design().controlName(Types_ProductType);
        var args = e as ValidateEventArgs;
        boolean result = args.parmValidateResult();
    
        if(..control..)
        {
            result  = checkFailed('%1',fc.text());
        }
        args.parmValidateResult(result);
    }

    community.dynamics.com/.../x-create-a-onvalidating-events-in-d365fo

  • Community Member Profile Picture
    on at
    [quote]

    I think you should hook into onValidated event, so that your code runs after the standard validation.

    You can check this example to understand how to set the return value of the validation (it's about a validateWrite event on a table, so there's some homework for you to apply it to your scenario): d365solution.blogspot.com/.../validatedwrite-eventhandler-d365-at.html

    I also warmly recommend Chain of Command if you want to avoid confusion, since it's much simpler and less confusing than events :)

    [/quote]

    Form dont contain any tables in datasources .

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Form dont contain any tables in datasources

    Yes, that's when the "homework" that I mentioned comes into play :)

  • Community Member Profile Picture
    on at

    I appreciate your playful mood , but I cant guess your logic. I made this thread to get some answers not more questions.

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    Reading your first post again, I think you actually don't even have any problems in the validation itself (set true/false based on a condition). Am I correct? But you don't know how to read the value of the form control?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans