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

Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetLabel

(0) ShareShare
ReportReport
Posted on by 351

Hi all,

I want to get my table fields label all fields.

Etc: I have a fields name lookup (If i give it to field name its aginst labels i want to show another field)

So that i wrote below,

 using Microsoft.Dynamics.AX.Metadata.MetaModel; // is it my table top as i declacred 
 public void modifiedField(FieldId _fieldId)
    {
        super(_fieldId);

        if(_fieldId == fieldNum(Translator, OriginalText))
        {
            AxLabelFile labels = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetLabel( ?)
       
            var fields = labels.Label;
           
            AxLabelFile  label;

            this.OriginalText = label.LabelFileId;
        }
    }

I'm wondering how to make that happen in metadata.

Thanks 

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

    You description is difficult to understand. Your code look like you're looking for a single label, but your description mentions "all fields"; I'll assume you want the label ID of a single table field.

    First of all, ask yourself if you need to use reflection. Can't you simply utilize fieldPName()?

    If you must use the metadata API, do something like this:

    using Microsoft.Dynamics.AX.Metadata.MetaModel;
    ...
    AxTableField field = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetTableField(tableStr(CustTable), fieldStr(CustTable, AccountNum));
    str label = field.Label;
    if (!label && field.ExtendedDataType)
    {
        AxEdt edt = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetEdt(field.ExtendedDataType);
        label = edt.Label;
    }
    info(label);

    Note that the label may also be defined on one of the parent EDTs. You may want to add this logic too, but let's keep is simple for now.

  • waytod365 Profile Picture
    351 on at

    Thanks for your valuable answer,

    Sir, its not a single label i want to table all fields labels.

    Etc: Field name (lookup 14 fields show) If i give it to in the field name(request date) and original text i want to request date label automatically. so that how to do sir?

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

    I'm sorry, but I don't understand what problem you're talking about at the moment.

    If you want to get a label for the field name that you select in a lookup, don't you already have a solution for that? What problem do you have with it?

    And if you want to show the label already in the lookup, isn't the solution still the same? You'll just apply it all fourteen fields one by one.

  • André Arnaud de Calavon Profile Picture
    301,049 Super User 2025 Season 2 on at

    Hi waytod365,

    I wonder what exactly you try to achieve here. When reading your coding, it looks like when someone will modify the field OriginalText, you want to overwrite this same field directly with another value.

    I can't match the coding with the other explanations you provided in this thread.

  • waytod365 Profile Picture
    351 on at

    Thanks for replay to you and andre sir,

    public void modifiedField(FieldId _fieldId)
        {
            super(_fieldId);
    
            if(_fieldId == fieldNum(Translator, FieldName))
            {
                DictTable       dt =new SysDictTable(tableNum(Translator));
                _fieldId=    dt.fieldNext(0);
                DictField     _dictField;
               
           
                _dictField  = dt.fieldObject(_fieldId);
                
                this.OriginalText = _dictField.label();
                   
                
            }
        }

    Sir, i know u can understand the code what i need and as i mentioned the code its first field only come label remaining not working

    Note :that 13 fields come in translator table. what am i doing wrong above code? if i choose any fields in translator table then its come label based on a choose field.

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

    Do you realize that your code always look for the label of the first field only? Is it really what you want?

    Let me fix some issues in your code (such as the fact that you're overwriting the value of the _fieldId parameter) and comment it a bit:

    public void modifiedField(FieldId _fieldId)
    {
    	super(_fieldId);
    
    	if (_fieldId == fieldNum(Translator, FieldName))
    	{
    		DictTable dictTable = new SysDictTable(tableNum(Translator));
    		// Here you're asking for the first field
    		FieldId fieldId = dictTable.fieldNext(0);
    		DictField dictField = dictTable.fieldObject(_fieldId);
    	      
    		// Let's show the field you're working with (for debugging purposes)
    		info(dictField.name());
    		
    		this.OriginalText = dictField.label();
    	}
    }

    I would think that you want to use the value of FileName field, but you completely ignore it in your code. Wouldn't this be closer to your goal?

    public void modifiedField(FieldId _fieldId)
    {
    	super(_fieldId);
    
    	switch (_fieldId)
    	{
    		case fieldNum(Translator, FieldName):
    			SysDictField dictField = SysDictField::newName(tableStr(Translator), this.FieldName);
    			this.OriginalText = dictField.label();
    			break;
    	}
    }

  • waytod365 Profile Picture
    351 on at

    Thank you very much sir, your code amazing i leant.

    Now, its works great.

  • waytod365 Profile Picture
    351 on at

    Sorry sir, small additional doubt in same code:-

     public void modifiedField(FieldId _fieldId)
        {
            //Args args = new Args();
            //TableName tableName = this.dataSource().cursor()
            super(_fieldId);
    
            switch (_fieldId)
            {
                case fieldNum(Translator, FieldName):
    
                    SysDictField dictField = SysDictField::newName(tableName), this.FieldName);
                    this.OriginalText = dictField.label();
                    break;
            }
        }
    

    As i mentioned above code, i will use multiple forms so i don't wanna specify one form is there any possible.

    Note : fields name i did automatically based on a caller form its works.

    Now, i want to based on caller label name its possible ? how can i do sir.

    Thanks. 

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

    I'm sorry, but I have no idea what you're talking about. There is no reference to any form in my code.

    Please show us the code you have in mind, the one where you're doing something with the caller form. Then explain your code to us and tell us how you would like to change its behavior.

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