Skip to main content

Notifications

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 

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: COC active method in D365Fo

    Thank you very much blue wang.

  • Verified answer
    Blue Wang Profile Picture
    on at
    RE: COC active method in D365Fo

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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,110 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans