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

Announcements

Community site session details

Community site session details

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

COC active method in D365Fo

(0) ShareShare
ReportReport
Posted on by 1,215

Hi guys,

i wrote an event handler one condition its working fine same i want to achieve in the COC so that

i did an Control name set as a "auto declaration" 'YES '

My  event handler code below,

  [FormDataSourceEventHandler(formDataSourceStr(HRMCourseAttendee, HRMCourseAttendee), FormDataSourceEventType::Activated)]
    public static void HRMCourseAttendee_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        HRMCourseAttendee courseAttendee = sender.formRun().dataSource("HRMCourseAttendee").cursor();
        FormButtonGroupControl course = sender.formRun().design().controlName("Course") as FormButtonGroupControl;
        course.enabled(courseAttendee.status == HRMCourseAttendeeStatus::Confirmation);
    }

Coc code,

[ExtensionOf(formDataSourceStr(HRMCourseAttendee, HRMCourseAttendee))]
final class HRMCourseAttendee_Extension
{
    public int active()
    {
        int ret;
        
        ret = next active();
        
        CourseCertificate.enabled(HRMCourseAttendee.Status == HRMCourseAttendeeStatus::Confirmation);
        return ret;
    }

}

"CourseCertificate" not declared am getting error please let me know how to achieve same logic in the COC?

Thanks 

I have the same question (0)
  • Verified answer
    Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Riyas,

    So, CourseCertificate is form control, right?

    In your class, you used formDataSourceStr, I think You will receive an error outside the scope of the variable.

    Try this:

    [ExtensionOf(formDataSourceStr(HRMCourseAttendee, HRMCourseAttendee))]
    final class HRMCourseAttendee_Extension
    {
        public int active()
        {
            HRMCourseAttendee HRMCourseAttendee = this.cursor();
            FormButtonGroupControl CourseCertificate = this.formRun().design().controlName("CourseCertificate") as FormButtonGroupControl;
            int ret;
            
            ret = next active();
            
            CourseCertificate.enabled(HRMCourseAttendee.Status == HRMCourseAttendeeStatus::Confirmation);
            return ret;
        }
    
    }

  • Riyas ahamed F Profile Picture
    1,215 on at

    Thank you very much blue wang.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 280 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 207 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans