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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How can I get the selected value before I write it in the strigedit?

(0) ShareShare
ReportReport
Posted on by 578

Before writing to the stringedit, I want to validate the selected value, because I need to insert that value in another table.

gt1.JPG

public boolean validate()
{
GCuttingDieTable gCuttingTable;
boolean ret;

ret = super();

...

gCuttingTable.CuttingDieId = SELECTED VALUE;
gCuttingTable.CuttingDieCategory = 2;
gCuttingTable.CustAccount = GCalcTable.CustAccount;
gCuttingTable.insert();

...

return ret;

}

Thanks in advance!.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You can override validateField method on the table GCuttingDieTable to include validations and insertlogic on stringedit.

    Typically your code looks like below

    public boolean validateField(FieldId _fieldIdToCheck)
    {
        GCuttingDieTable  gCuttingDieTableLocal;
    
        boolean ret;
    
        ret = super(_fieldIdToCheck);
    
        if (ret)
        {
            switch (_fieldIdToCheck)
            {
                case fieldNum(GCuttingDieTable, Field):
                    select gCuttingDieTableLocal
                        where gCuttingDieTableLocal.Id == this.Field; // to include validations
                    // Include your insert code
                    break;
    
                default:
                    break;
            }
        }
    
        return ret;
    }


  • ismaelivan Profile Picture
    578 on at

    Thanks Chaitanya, but this form does not contain the gcuttingdietable table, I try to validate inside the GraCalcPrintBind form.

    The field is CuttingDieId (GCalcSheetLine)

    And i have the next code in Lookup Method...

    public void lookup()
    {
    
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;
    
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventDim), this);
    
    sysTableLookup.addLookupField(fieldNum(InventDim, InventBatchId));
    sysTableLookup.addLookupField(fieldNum(InventDim, wMSLocationId));
    sysTableLookup.addLookupField(fieldNum(InventDim, InventLocationId));
    
    queryBuildDataSource = query.addDataSource(tableNum(InventDim));
    
    queryBuildRange = queryBuildDataSource.addRange(fieldNum(InventDim, InventBatchId));
    sysTableLookup.parmQuery(query);
    
    sysTableLookup.performFormLookup();
    
    //super();
    
    }


  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Yeah, I mean you can write your code on validateField method of gcuttingdietable and include logic to insert data in other table.

  • ismaelivan Profile Picture
    578 on at

    This is my stringedit

    gt2.JPG

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Use this statement in your validate method:

    gCuttingTable.CuttingDieId = this.valueStr();

    and your code looks like

    public boolean validate()
    {
    GCuttingDieTable gCuttingTable;
    boolean ret;
    
    ret = super();
    
    ...
    
    if (ret == true)
    {
       gCuttingTable.CuttingDieId = this.valueStr();
       gCuttingTable.CuttingDieCategory = 2;
       gCuttingTable.CustAccount = GCalcTable.CustAccount;
       gCuttingTable.insert();
    }
    
    ...
    
    return ret;
    
    }
  • ismaelivan Profile Picture
    578 on at

    I had already tried whit "gCuttingTable.CuttingDieId = this.valueStr ();" but the stringedit has no value. 

    Because before validates if that value exists in the GCuttingDieTable table.

    gt3.JPG

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Can you provide your screenshot with error in english and I think there is some problem with your lookup, can you provide that code too.

  • ismaelivan Profile Picture
    578 on at

    The mistake is "The value '319177-P130074-CAJA' in field 'CuttingDieId' is not found in the related table 'gCuttingTable.'"

    The values in the combo come originally from the InventDIm table, but when you select one in the list, I create a new record in GCuttingDieTable with those 3 columns. For that reason I need to obtain the values or only the recid of the selected row.

    1854.gt6.JPG

    1854.gt6.JPG

  • ismaelivan Profile Picture
    578 on at

    The solution was to create a new lookup form, and from there get the recid to send it to a method in the caller form.

    public void closeSelect(str _selectString)
    {
    
        super(_selectString);
    
        if(this.args().caller().name() == "GraCalcPrintBind")
        {
            this.args().caller().MyMethod_GetRecId(InventDim.RecId);
        }
    }


    Thank very much!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans