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

Notifications

Announcements

No record found.

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
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans