Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

refresh display method fields x++

(0) ShareShare
ReportReport
Posted on by 163

In form of past workers : when I edit value of reason code field from employment history data doesn't refresh until I refresh browser when I refresh form data still doesn't pass 

How can I refresh browser or refresh this field by code I tried these ways but no thing worked 

axcompendium.wordpress.com/.../

  • Martin Dráb Profile Picture
    Martin Dráb 230,569 Most Valuable Professional on at
    refresh display method fields x++
    I see many things wrong, and indeed, you never call markChanged(). Please look again at the example in Display methods and Form Observability a change your implementation accordingly.
     
  • Menna Allah Ahmed Profile Picture
    Menna Allah Ahmed 163 on at
    refresh display method fields x++
    Display method in hcmworker datasource 
    there is code of datasource extension 
    [ExtensionOf(formDataSourceStr(HcmWorker,HcmWorker))]
    
    final class HcmWorkerHcmWorkerDS_Extension
    {
    	[SysClientCacheDataMethodAttribute(true)]
        public display str displayHiringStatus(HcmWorker _worker)
        {
            this.observe();
            return this.getLatestPastEmploymentDetailCFM(_worker).HiringStatus;
        }
    
        private HcmEmploymentDetail getLatestPastEmploymentDetailCFM(HcmWorker _worker)
        {
    
            HcmEmploymentDetail employmentDetail;
            Map workerLatestPastEmploymentDetail = element.workerLatestPastEmploymentDetail;
    
    
            if (!workerLatestPastEmploymentDetail)
            {
                workerLatestPastEmploymentDetail = new Map(Types::Int64, Types::Record);
            }
    
            if (!workerLatestPastEmploymentDetail.exists(_worker.RecId))
            {
                employmentDetail = HcmWorkerHelper::getLatestPastEmploymentDetail(_worker.RecId);
                workerLatestPastEmploymentDetail.insert(_worker.RecId, employmentDetail);
            }
            else
            {
                employmentDetail = workerLatestPastEmploymentDetail.lookup(_worker.RecId) as HcmEmploymentDetail;
            }
    
            return employmentDetail;
        }
    
    }
     
    I called this.observe in display method doesn't work also I tried to add FormObservableLink in HcmWorker Form 
    [ExtensionOf(formStr(HcmWorker))]
    Final class HcmWorkerForm_Extension
    {        
    	public FormObservableLink linesTotalObservableLink;
    
        public void refreshTotals()
        {
            linesTotalObservableLink.observe();
        }
     
    
        void init()
        {
    
            next init();
            //infolog.clear();  //need to check feature first
            linesTotalObservableLink = new FormObservableLink();
    
            if(this.args().menuItemName() == menuItemDisplayStr(HcmWorkerListPage_PastWorkers))
            {
                HRWorkerTerminationCFM.enabled(false);
                HRWorkerTerminationCFM.visible(false);
                HiringStatus.visible(true);
            }
    	}
     
    Then I called method if refreshTotals in code that updated hiringstatus in HcmEmploymentDetail 
    [ExtensionOf(formControlStr(HcmEmploymentDialog, ModifyEmploymentButton))]
    final class HcmEmploymentDialog_Button_Extension
    {
        private readonly utcdatetime neverInUserTimeZone = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());
        private readonly utcdatetime utcDateTimeNull = utcDateTimeNull();
        void clicked()
        {
            boolean ret = this.hasMandatoryDates(true);
            FormReferenceGroupControl	TerminationReasonCode = this.formRun().design().controlName('TerminationReasonCode');
            FormStringControl			HiringStatus = this.formRun().design().controlName('HiringStatus');
            FormRun FormRun1 ;
            FormRun FormRun2 ;
            utcdatetime MaxDateTime = DateTimeUtil::maxValue();
            utcdatetime currentDateTime = DateTimeUtil::utcNow();
        
            next clicked();
    
            if((element.args().parmEnum() == HcmEmploymentAction::End||element.args().parmEnum() == HcmEmploymentAction::Edit)
                && ret && element.validateDates())
            {
                FormRun1 = element.args().caller();
                FormRun2 = FormRun1.args().caller();
                FormDataSource HcmWorker_ds = FormRun2.dataSource('HcmWorker');
                FormDataSource HcmEmploymentDetail_ds = FormRun2.dataSource('HcmEmploymentDetail');
    
                ttsbegin;
                HcmEmployment hcmEmployment =    element.getHcmEmployment();
                HcmEmploymentDetail HcmEmploymentDetail = HcmEmploymentDetail::findByEmployment(hcmEmployment.RecId);
                HcmEmploymentDetail.selectForUpdate(true);
                hcmEmploymentDetail.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
                hcmEmploymentDetail.HiringStatus = HiringStatus.valuestr();
                hcmEmploymentDetail.update();
                ttscommit;
                HcmWorker_ds.observe();
                HcmEmploymentDetail_ds.observe();
                if (FormRun2 && Global::formHasMethod(FormRun2, formMethodStr(HcmWorker, refreshTotals)))
                {
                    FormRun2.refreshTotals();
                }
                FormRun2.dataSource('HcmWorker').research(true);
                FormRun2.dataSource('HcmWorker').refresh();
    
            }   
    
        }
    
    
    }
    There are all ways I tried but nothing is working
  • Martin Dráb Profile Picture
    Martin Dráb 230,569 Most Valuable Professional on at
    refresh display method fields x++
    Menna, when do you want to do the refresh? There you should call markChanged() of FormObservableLink, but you don't seem to have any such code. That's why your observable link doesn't do anything.
  • Menna Allah Ahmed Profile Picture
    Menna Allah Ahmed 163 on at
    refresh display method fields x++
    I still have this issue I tried all this ways didn't work 
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: refresh display method fields x++

    Try this.

    ievgensaxblog.wordpress.com/.../

    Also it seems due to caching of the display method using that attribute on the method. Can you try removing that and check? But this is not advisable as it is for performance.

  • Menna Allah Ahmed Profile Picture
    Menna Allah Ahmed 163 on at
    RE: refresh display method fields x++

    I tried all of this and build full model but didn't work

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: refresh display method fields x++

    Hi menna,

    Refer to the below blog and see if it helps.

    https://dynamicsaxknowledge.wordpress.com/2019/07/13/refresh-display-methods/

    Thanks,

    Girish S.

  • Menna Allah Ahmed Profile Picture
    Menna Allah Ahmed 163 on at
    RE: refresh display method fields x++

    I got data source from form and value appear in debug but to make me see it in grid I need to refresh browser not form only ,

    I can't find how can I refresh these fields of display method on grid

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: refresh display method fields x++

    I assume that you have Form A where you have some button and onclick new form B is opening and there you are changing the value but it is not updating in display method in Form A.

    Ideally in this scenario it should be in close method of Form B as you said. Then you need to debug and see if you are able to get the form A datasource.

  • Menna Allah Ahmed Profile Picture
    Menna Allah Ahmed 163 on at
    RE: refresh display method fields x++

    now I changed values in form employment history that have reason code ,

    this value of reason code pass to display method in from hcm worker

    where you need me to write code on modified ?

    in form employment history ?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,883 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans