web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Initialize a field value when another field has changed

(1) ShareShare
ReportReport
Posted on by 40

Hai I am trainee technical consultant. This is the task given to me . I tried my best to create the table, but I am unable to meet the requirement asked in Cubical master table>FloorDescription> DataType to achieve the description value from the floor master table.

I tried it by using Modifiedfield method but I am not able to get succeeded please help me in this aspect.

thanks in advance.

 

Floor master:

S.No Field Name Label Mandatory DataType Size
1 FloorId Floor Id Yes String 10
2 Description Description No String 60

Cubicle master:

S.No Field Name Label Mandatory DataType Size
1 CubicleId Cubicle Id Yes String 10
2 Description Description No String 60
3 FloorId

Floor Id

Yes String 10
4 FloorDescription Floor Description No

Non-Editable.

Default FloorID Description

From Floor master

-

 

I have the same question (0)
  • Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    Does it mean that you want to copy Decription from Floor master table? I wonder if it's good design, but I guess it's not up to you at the moment. If you want to do it immediately when FloorId changes, modifiedField() is the right method. But I can't comment on your problem there, because you neither showed your code nor explained what problem you have with it.

    By the way, let me changed the thread category from "Other" to "Development / Customization / SDK" and try to set a more descriptive title.

  • Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    Title changed from "Help me in creating the below said tables as per the requirement." to "Initialize a field value when another field has changed".

  • AxAspirant Profile Picture
    40 on at

    Yes I need to copy Description from floor master table to FloorDescription in Cubicle master.

    This is the code that I worked on it but its not copying the values as required.

    Code:

    public void modifiedField(FieldId _fieldId)

       {

           FloorMaster floorMaster;

           super(_fieldId);

           switch(_fieldId)

           {

               case fieldNum(CubicalMaster,FloorId):

                   this.FloorDescription = floorMaster.Description;

                   break;

               default:

                   break;        

           }

       }

  • Verified answer
    Martin Dráb Profile Picture
    237,896 Most Valuable Professional on at

    Please use Insert > Insert Code (switch to rich formatting to view this option) to paste source code. It uses single line spacing, provides line numbering, make code easier to copy and so on. This is the result:

    public void modifiedField(FieldId _fieldId)
    {
       FloorMaster floorMaster;
       
       super(_fieldId);
       
       switch(_fieldId)
       {
    	   case fieldNum(CubicalMaster,FloorId):
    		   this.FloorDescription = floorMaster.Description;
    		   break;
    	   default:
    		   break;
       }
    }

    If you debugged your code, you would have found that this.FloorDescription is empty because you assign an empty value to it. (As you see, the debugger can give you a lot of important information - make sure you use it.)

    The reason is in the fact that you never assigned anything to floorMater variable, therefore it has all fields empty. What you need to do is finding the FloorMaster record for the given FloorId. For example:

    public void modifiedField(FieldId _fieldId)
    {
    	super(_fieldId);
    
    	switch(_fieldId)
    	{
    		case fieldNum(CubicalMaster, FloorId):
    			FloorMaster floorMaster = FloorMaster::find(this.FloorId);
    			this.FloorDescription = floorMaster.Description;
    			break;
    	}
    }

    If FloorMaster doesn't have find() method, go and add it. You can find a plenty of examples in existing tables, but if you struggle with it anyway, feel free to ask.

    public void modifiedField(FieldId _fieldId)
    {
        FloorMaster floorMaster;
    
    	super(_fieldId);
    
    	switch(_fieldId)
    	{
    		case fieldNum(CubicalMaster, FloorId):
    			floorMaster = FloorMaster::find(this.FloorId);
    			this.FloorDescription = floorMaster.Description;
    			break;
    	}
    }

  • AxAspirant Profile Picture
    40 on at

    I got it as needed. Thanks for u help and time on investing to help me @Martin Dráb

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans