Skip to main content

Notifications

Announcements

No record found.

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

pass date value between forms

Posted on by 2,016

Greeting everyone

i've created a new form

in my new form if i selected worker i need to populate date on my form automatically from other form 

let me explain more

when chose worker

pastedimage1614680354893v3.png

i need to populate expiration date

from this form 

pastedimage1614680241318v2.png

so i crated modify method on worker grid

pastedimage1614680568382v4.png

and here my code

public boolean modified()
{
    boolean ret;

    HcmWorker   hcmWorker;
    HcmIdentificationType   hcmIdentificationType;
    HcmPersonIdentificationNumber   hcmPersonIdentificationNumber;
    int64 TypeId;
    int64 personId;
    date idend;


    select firstOnly RecId from hcmIdentificationType where hcmIdentificationType.Description =="Passport";
    TypeId=hcmIdentificationType.RecId;

    select Person from hcmWorker where hcmWorker.recid == this.value();
    personId=hcmWorker.Person;


    select ExpirationDate from hcmPersonIdentificationNumber where hcmPersonIdentificationNumber.Person==personId &&
    hcmPersonIdentificationNumber.IdentificationType==TypeId;
    idend=hcmPersonIdentificationNumber.ExpirationDate;


    Grid_ExpireDate.dateValue(idend);
    Grid_ExpireDate.modified();


    ret = super();


    return ret;
}

but still not change date on my custom grid

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: pass date value between forms

    If it's linked to a data source field, then the field will show the data source field!

    And your code should update that table field, instead of trying to force the form to show something else.

    Another question is why would you want to have this field in your table. You need extra effort to keep the field up to date. Remember that changing the worker is not the only situation when you might want to update this field. Changes in the underlying data (hcmPersonIdentificationNumber table) would also need to be handled.

    My suggestion is: don't duplicate this data, it already exists in hcmPersonIdentificationNumber table. Instead create a solution that reads data from that table when you need it (on forms, business processes, reports etc).

  • mohammed.mqi Profile Picture
    mohammed.mqi 2,016 on at
    RE: pass date value between forms

    thanks for replay 

    yes that field linked to data source field

    pastedimage1614693387440v1.png

    pastedimage1614693223274v1.png

    and not even display today's date

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: pass date value between forms

    Ok and is the date field linked to some data source field / method?

    Anyway if not, add this method in the data source table:

    public display Date dsplMyDate()
    {
        return today();
    }

    And point the "data source" and "data method" properties of your date field to this data source and method.

    Does it now display today's date?

    Once it does, you must next add logic to this method, to display the required date based on the selected worker.

  • mohammed.mqi Profile Picture
    mohammed.mqi 2,016 on at
    RE: pass date value between forms

    yes i did debug it

    pastedimage1614691349978v2.png

    and it's already linked to a data source table

    pastedimage1614691277985v1.png

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: pass date value between forms

    Was the code executed? Did you debug it and verify that it's working?

    Anyway, since you're using a grid, this approach won't even work.

    First of all, a grid should always be linked to a data source table. Is your grid linked to a data source table?

    Second, you should use a display method to display calculated values on the grid.

  • mohammed.mqi Profile Picture
    mohammed.mqi 2,016 on at
    RE: pass date value between forms

    thanks for reply 

    i did as you said but still that field empty 

    as you see here

    pastedimage1614689035451v1.png

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: pass date value between forms

    Ok, so let's try to remove everything that is irrelevant for troubleshooting this problem, and try to put this in the modified method (just to try it out):

    public boolean modified()
    {
        Grid_ExpireDate.dateValue(today());
    
        return super();
    
    }

    If you now modify your field (so that modified method is triggered), does the value in the date field update to today's date?

  • mohammed.mqi Profile Picture
    mohammed.mqi 2,016 on at
    RE: pass date value between forms

    yes your correct

    I thought in the beginning i can pass date value between forms but actually i need to set value in date control and the date from "idend"

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: pass date value between forms

    If I understood correctly, you were unable to find that the issue is in lines 25-26. So the issue is in setting value in the date control. Correct? So we can forget about "pass date value between forms" and focus on "how to set value in date control". And you are also saying that you have a date in "idend" variable. Correct?

  • mohammed.mqi Profile Picture
    mohammed.mqi 2,016 on at
    RE: pass date value between forms

    thanks for replay 

    the issue about line 25 and line 26 not applay 

    so that not change or add date value to the field (ExpireDate) on gridview 

    how can i populate that field?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans