简体   繁体   English

如何使用 x++ 从字符串字段自动填充查找字段?

[英]How can I auto populate a lookup field from a string field with x++?

I am new at d365 Finance and Operations我是 d365 财务和运营部门的新员工

I have a form and fields in it.我有一个表格和字段。 Every time I enter a new record of one of these fields, their values should be concatenated and the combined text put to the 'Details' field.每次我输入这些字段之一的新记录时,它们的值应该连接起来,并将组合文本放入“详细信息”字段。 2 fields are string and I use Modified events for them but the other field is lookup. 2 个字段是字符串,我为它们使用修改事件,但另一个字段是查找。 How can I get the 'name' field in the lookup field to be written to the 'details' field?如何将查找字段中的“名称”字段写入“详细信息”字段? If anyone helps me with this I would be really appreciated it.如果有人帮助我,我将不胜感激。

Here is my code for string fields;这是我的字符串字段代码;

[
    FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field1), FormDataFieldEventType::Modified),
    FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field2), FormDataFieldEventType::Modified)
   
]
public static void Field1_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        // get the form DataSource
        FormDataSource dataSource = sender.datasource();
    
        // get current record
        InventSite inventSite = dataSource.cursor();
        
        
    
        // contatenate string values
        str details = strFmt("%1, %2",  inventSite.Field1, inventSite.Field2);
        

And here is my lookup field.这是我的查找字段。 Thank you very much in advance... My lookup field非常感谢您...我的查找字段

If I need to explain more clearly, the value that I want to get is in the reference group (type: int64) I need to get its 'name(control name)' value, and Like others (field1 and field2, I need it to be written automatically in the 'details' field. please help...如果我需要解释的更清楚,我要获取的值在引用组中(类型:int64)我需要获取它的'name(控件名称)'值,并且像其他人一样(field1和field2,我需要它自动写入“详细信息”字段。请帮助...

Create static findByRecId method for your LookupTable (use class extension if it's a standard table).为您的LookupTable创建 static findByRecId方法(如果它是标准表,请使用 class 扩展)。 Then modify your code:然后修改你的代码:

[
    FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field1), FormDataFieldEventType::Modified),
    FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field2), FormDataFieldEventType::Modified)
    FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field3), FormDataFieldEventType::Modified)      
]
public static void Field1_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        // get the form DataSource
        FormDataSource dataSource = sender.datasource();
    
        // get current record
        InventSite inventSite = dataSource.cursor();            
               
        // contatenate string values
        str details = strFmt("%1, %2, %3",  inventSite.Field1, inventSite.Field2, LookupTable::findByRecId(inventSite.Field3).Name);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM