Skip to main content

Notifications

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

HRM Fixed Compensation dialog form custom field issue

(0) ShareShare
ReportReport
Posted on by 191

Hi Community experts,
 
I am having a problem with the Form named /HcmCompFixedEmplActionDialog/.
Navigation: Worker> Fixed Plan> New
 
 

 

 
What I am trying to do with this form is, I have added a custom field on it and I want to save this field's value in the Table /HRMCompFixedEmpl/ which is the base table and datasource for the main form /HRMCompFixedEmpl/.
The main form only allows to insert a new record via this dialog form /HcmCompFixedEmplActionDialog/ and this dialog form does not have any datasource associated with it. All the fields on the form are getting values/data through the form's code and a class named /HrmCompFixedEmplAction/.
 
 

 


I have tried different CoCs but its not working for me. Didn't find the correct method/class to extend.
I wrote CoC for the OkButton (CloseOkay Method of form) but strange enough I found out the record in table /HRMCompFixedEmpl/ is not created right after the OkButton is clicked. So I can not update the table because there's no buffer at the time of click on OkButton. But my field resides on the Dialog form so I am limited/bound with this dialog form somehow. I have written a CoC for this form's class where I have stored the value of this custom field (real type form control) in a variable and returning it through a method. But I am stuck with not knowing the correct class or method to pass it to at the right time of execution.
 
My only goal is to insert the value of this custom dialog field into the table /HRMCompFixedEmpl/ when OkButton is clicked.
 
Looking forward to usual helpful responses on this.
 
Best Regards.
  • alinawaz Profile Picture
    alinawaz 191 on at
    HRM Fixed Compensation dialog form custom field issue
    Hi Martin,
     
    I have tested the suggested change and I have found out the edit method is only working when there's a new record created in terms of existing record.
     
     
    The data is not getting inserted/updated when I create record with "New" button and "Update current compensation" button.
    And the initValue method is only getting called for "Update current compensation" button and "New Compensation action" button. For "New" button initValue is not getting called.
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    HRM Fixed Compensation dialog form custom field issue
    If you parm method isn't called at all, verify that the edit method (ugandaStiOffset()) is called. If it's not called either, we know that we have a problem even before that. If it gets called, you can walk through code and see where things go wrong.
     
    Your statement that initValue() isn't called sounds suspicious to me. Let me repeat how I think it works:
    1. closeOk() on the form calls HrmCompFixedEmplAction.setupHRMCompFixedEmpl(). It's done always; there is no condition for new or updated records.
    2. There is only a single thing that setupHRMCompFixedEmpl() does: it calls initValue(). Again, there is no condition.
    What different behaviour do you see when you debug the code?
  • alinawaz Profile Picture
    alinawaz 191 on at
    HRM Fixed Compensation dialog form custom field issue
    Hi Martin,
    The code snippet action is broker its not letting me post the code, so I am pasting the code as text.
     
    1 - Here's the code for my action extension class:
     
    [ExtensionOf(classStr(HrmCompFixedEmplAction))]
    final class CCBHrmCompFixedEmplActionClass_Extension
    {
        public real ugandaSTIOffset;
        public void initMembers()
        {
            next initMembers();
            ugandaSTIOffset = hrmCompFixedEmpl.CCBStiOffset;
        }
        protected void initValue(HRMCompFixedEmpl _hrmCompFixedEmpl)
        {
            next initValue(_hrmCompFixedEmpl);
            _hrmCompFixedEmpl.CCBStiOffset = ugandaSTIOffset;
        }
        public real parmUgandaSTIOffset(real _ugandaSTIOffset = ugandaSTIOffset)
        {
            ugandaSTIOffset = _ugandaSTIOffset;
            return ugandaSTIOffset;
        }
    }
     
    2 - Here's the code for my dialog form extension class:
     
    [ExtensionOf(formStr(HcmCompFixedEmplActionDialog))]
    public final class CCBHcmCompFixedEmplActionDialog_Extension
    {

        public edit real ugandaStiOffset(boolean set, real _ugandaStiOffset)
        {
            if (set)
            {
                compFixedEmplAction.parmUgandaSTIOffset(_ugandaStiOffset);
            }
       
            return compFixedEmplAction.parmUgandaSTIOffset();
        }
    }
     
    While debugging I have seen this issue, the variable is not getting populated with the value of form control at all. The parm method is not storing value in variable. Maybe the parm method is not getting called at that time. I have tried putting a debugger on it and it doesn't get hit.
    The second strange issue I saw while debugging is, the initValue method is not getting called while creating a new record. It is only triggered/called while updating the existing record on the form.
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    HRM Fixed Compensation dialog form custom field issue
    If you set the value to your own object, it won't have any effect on the standard logic. Your object with the value will cease to exist when the form is closed on and the standard instance of HRMCompFixedEmplActionDialog class will still contain the same data as if you never wrote any code.
     
    But sounds like your variable isn't ever used anyway - you'd get a null reference exception if it was, because you never created an instance.
     
    What was your motivation of creating such a variable? I guess you got this (bad) idea because you're trying to deal with some problem.
     
    By the way, can't you show your complete code (as text, using Insert Code Snippet)?
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    HRM Fixed Compensation dialog form custom field issue
    Oh, sorry that was my mistake. There is another child class for HrmCompFixedEmplAction which is HrmCompFixedEmplActionTransfer - Inside this class there is a method named "insertFixedEmplRecord" - Try to write COC for this method and check. Also please debug how the classes are initialized.
     
    Thanks,
    Girish S.
  • alinawaz Profile Picture
    alinawaz 191 on at
    HRM Fixed Compensation dialog form custom field issue
    Girish I believe you are looking at a different form code.
     
    The form I am working with is "HcmCompFixedEmplActionDialog" you are looking at "HRMCompFixedEmplActionDialog"
     
     
    The class buffer in "HcmCompFixedEmplActionDialog" form is declared as "compFixedEmplAction" which I was using earlier in my code before declaring a new variable of this class type.
     
     
    My extension class:
     
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    HRM Fixed Compensation dialog form custom field issue
    This is the issue - You are creating new buffer for HrmCompFixedEmplAction class which is wrong.
    You need to use the same buffer which declared in the form.
     
    Thanks,
    Girish S.
  • alinawaz Profile Picture
    alinawaz 191 on at
    HRM Fixed Compensation dialog form custom field issue
    Hi @girish
     
    I have added the class buffer in the dialog form extension class. But the problem still persists
     
     
    The extension class for "HrmCompFixedEmplAction" in unchanged though.
     
     
    One more thing I have noticed is when I put the debugger on initValue method in extension class, it doesn't hit the break point. Whereas the actual initValue method get hit in the debugger.
     
    I am kind of baffled by this situation right now, can you point me in the correct direction please?
     
    Best Regards
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    HRM Fixed Compensation dialog form custom field issue
    Where did you declare the buffer "compFixedEmplAction"?
    In the form there is a global variable for HrmcompFixedEmplAction class "hrmCompFixedEmplAction" - You need to use this buffer in your custom edit method.
     
    Thanks,
    Girish S.
  • alinawaz Profile Picture
    alinawaz 191 on at
    HRM Fixed Compensation dialog form custom field issue
    Hi Guys,
     
    Thanks for your valuable suggestions, I have followed the suggestions but still stuck with the same problem.
    1- Created edit method in Dialog class extension
    2 - Added variable in Action class extension
    3 - Added parm method in Action class extension
    4 - Wrote CoC of InitValue method in Action class extension
     
     
     
    When I am clicking the Ok button from front-end its still not saving the value of my custom field in the table, Rest of the default fields are getting inserted but not my custom field.
     
    Can you guys please specify what mistake I have made here?
    Best Regards

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans