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 :
Dynamics 365 Community / Forums / Finance forum / Set Value FormDateControl
Finance forum

Set Value FormDateControl

(0) ShareShare
ReportReport
Posted on by 245

How can I set value FormDateControl ? 

[FormControlEventHandler(formControlStr(AssetProposalDepreciation, ToDateControl), FormControlEventType::Modified)]
    public static void ToDateControl_OnModified(FormControl sender, FormControlEventArgs e)
    {
        str strToDate = sender.valueStr();
        date dateToDate = str2Date(strToDate, 0);
        date dateEndMonth = endMth(dateToDate);
        sender.valueStr(date2str(dateEndMonth, 123, DateDay::Digits1or2, DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4));
    }

In that script, i have an error in sender.valueStr()

Can anyone help me ? 

Thanks

  • udaY-ch Profile Picture
    5,186 on at
  • Verified answer
    Rangga Pramana Profile Picture
    245 on at

    I have done

    here my code : 

    [FormControlEventHandler(formControlStr(AssetProposalDepreciation, ToDateControl), FormControlEventType::Modified)]
        public static void ToDateControl_OnModified(FormControl sender, FormControlEventArgs e)
        {
            FormDateControl dateControl = sender as FormDateControl;
            TransDate strToDate = dateControl.dateValue();
            TransDate endDate = endMth(strToDate);
            dateControl.dateValue(endDate);
        }


  • Rustem Galiamov Profile Picture
    8,072 on at

    Try to declare FormControl variable like FormControl toDateControl = sender as FormControl; and then use toDateControl.valueStr().

  • Verified answer
    Martin Dráb Profile Picture
    240,742 Most Valuable Professional on at

    If the control is bound to a data source, change the value of the datasource field.

    It it's an unbound control, the right method is dateValue().

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Just to add to Martin suggestion, you don't need to use str variable if you want to get date value.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans