Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to populate one field data to other form field - During a create action

(0) ShareShare
ReportReport
Posted on by 160

Hi,

There is one  form1 with field item id. 

Once you click on "Create" button in action pane, another dialog form2 opens, where there is a field names item id. 

Now once create action is initialized, the form 1 item id must be auto populated in the item field in form 2 dialog form. 
 
Both the form uses same table. 

I used init method on form 2, but it is not working.  Any help?

  • RSX Profile Picture
    RSX 160 on at
    RE: How to populate one field data to other form field - During a create action

    Hi Martin,

    Thank you.

    I used initvalue and now the value is getting updated.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,503 Most Valuable Professional on at
    RE: How to populate one field data to other form field - During a create action

    Is the Comx_AdditionalDetails record already saved in DB?

    If so, you should set a filter on the form instead of trying to populate the field only.

    It it's not, I think that the contents of Comx_AdditionalDetails gets overwritten when a new record gets created automatically (or maybe there is no record at all). initValue() of the data source may be a good place for this logic.

    Also, please always use Insert > Code (in the rich formatting view) to paste source code. It'll be easier to read and copy:

    Comx_AdditionalDetails gAdditionalDetails; //globally declared
    
    public void init()
    {
       super();
       
       if (element.args().record().tableId == tableNum(Comx_AdditionalDetails))
       {
    	   gAdditionalDetails = element.args().record();
    	   Comx_AdditionalDetails.itemNumber = gAdditionalDetails.itemNumber;
       }
    }

  • RSX Profile Picture
    RSX 160 on at
    RE: How to populate one field data to other form field - During a create action

    Hi Andre,

    Is not working means, there is no error, But it is showing empty record only.

    Code ::

    Comx_AdditionalDetails     gAdditionalDetails;   //globally declared

    public void init()

       {

           super();

           if(element.args().record().tableId == tableNum(Comx_AdditionalDetails))

           {

               gAdditionalDetails = element.args().record();

               Comx_AdditionalDetails.itemNumber = gAdditionalDetails.itemNumber;

           }

       }

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,431 Super User 2024 Season 2 on at
    RE: How to populate one field data to other form field - During a create action

    Hi RSX,

    Are you able to share the code you used in the init() method? Can you also describe what you mean with "is not working"? Do you get an error or a wrong or empty record?

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans