Skip to main content

Notifications

Announcements

No record found.

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

retrieve data fields data exists in WhsWorkLineCustom table to inventSum table in InventOnHandItem form

(0) ShareShare
ReportReport
Posted on by 5

I have added data of field "Data" exists in "WhsWorkLineCustom" table to "InventSum" table to the form "InventOnHandItem" and make them available for filtering and sorting using the standard filter function in the form grid .

I have tried several approaches without luck.

I have tried this code and when I do a debug the recId of "inventSum" Table is always null.

[ExtensionOf(tableStr(WHSWorkLine))]
final class WHSWorkLine_DEM_T_Extension
{
public void update()
{
next update();

InventDim InventDim;

WHSWorkLine wHSWorkLine;
WHSWorkTable wHSWorkTable;
InventSuminventSum;
WHSWorkLineCustom wHSWorkLineCustom;
wHSWorkLineCustom = wHSWorkLineCustom::find(this.WorkId,this.LineNum);
if (this.WorkType == WHSWorkType::Custom)
{
wHSWorkTable= WHSWorkTable::find(this.WorkId);

{

select forupdate inventSum where InventSum.InventDimId== InventDimId.InventDimId;
if (inventSum )
{
inventSum.Data = wHSWorkLineCustom.Data;
inventSum.update();
}


}

}
}

}

  • Martin Dráb Profile Picture
    Martin Dráb 230,340 Most Valuable Professional on at
    RE: retrieve data fields data exists in WhsWorkLineCustom table to inventSum table in InventOnHandItem form

    Does it mean that you're trying to build a query to fetch InventSum records related to a particular license plate ID? If so, than there is nothing like updating the Data field, as youd did in your code.

    What do you want to do with the query? For example, if your goal is displaying the data in a form, there is no point in fetching the data by a select statement in X++. You'll rather design a query with form data sources.

  • rrrr Profile Picture
    rrrr 5 on at
    RE: retrieve data fields data exists in WhsWorkLineCustom table to inventSum table in InventOnHandItem form

    Hi,

    we are in the module stock management->search and status->all jobs. we find a list of jobs that exists in the table "WHSWorkTable", I will select the goal is to retrieve the value of this field in the table "InventSum" that exists in the module Stock Management->list available according to the field "LicensePlateId" that exists in the table "InventDim" which is equal to the field "TargetLicensePlateId

    PS: I need a code thank you :)

  • Martin Dráb Profile Picture
    Martin Dráb 230,340 Most Valuable Professional on at
    RE: retrieve data fields data exists in WhsWorkLineCustom table to inventSum table in InventOnHandItem form

    Could you please forget implementation details for a moment and tell us what business problem you're trying to solve.

    I'm almost sure that your proposed solution is wrong, but it's impossible to suggest a better design without knowing what you're trying to achieve.

  • rrrr Profile Picture
    rrrr 5 on at
    RE: retrieve data fields data exists in WhsWorkLineCustom table to inventSum table in InventOnHandItem form

    Hi,

    thank you for your answer, but I can't find a solution please give me all the details to add the data of this field exists in "whsworklinecustom" table automatically in "inventsum" table when the record is automatically added in "inventsum" table the relation between "whsworktable" table and "inventsum" table is TargetLicenseId in "whsworkTable" and LicenceplateId in "InventDim" table  

    I find the InventUpdateOnhand class but I don't retrieve what  I do to retrieve the field "data" an to be  inserted automatically in "inventSum" table with other fields

    I tried the above  code and I specify in line 15 licenceplateId  but the field "data" is not inserted in table "inventsum" table

    I need a help plz  

  • Martin Dráb Profile Picture
    Martin Dráb 230,340 Most Valuable Professional on at
    RE: retrieve data fields data exists in WhsWorkLineCustom table to inventSum table in InventOnHandItem form

    First of all, let me improve your code - there are unused variables, it lacks indentation etc. This will be much easier to read:

    [ExtensionOf(tableStr(WHSWorkLine))]
    final class WHSWorkLine_DEM_T_Extension
    {
    	public void update()
    	{
    		next update();
    
    		if (this.WorkType == WHSWorkType::Custom)
    		{
    			WHSWorkLineCustom wHSWorkLineCustom = = wHSWorkLineCustom::find(this.WorkId, this.LineNum);		
    			InventSum inventSum;
    			InventDim inventDim;
    			
    			select forupdate inventSum
    				where InventSum.InventDimId == inventDimId.InventDimId;
    				
    			if (inventSum)
    			{
    				inventSum.Data = wHSWorkLineCustom.Data;
    				inventSum.update();
    			}
    		}
    	}
    }

    This code still won't even compile, because you're using a wrong name at line 15 - there is no inventDimId variable. You likely meant inventDim variable, but you're never populated it with any data, therefore it'll always be empty and you can't ever find any InventSum record with an empty InventDimId. You would easily see this problem if you look at variable values in debugger.

    The select statement is logically wrong, because you forgot to specify an item ID.

    The whole idea looks strange, if not wrong, to me. What's the purpose of having Data of the last updated WHSWorkLine in InventSum? InventSum contains summarized values. Also, note that is a perfomance-critical table, therefore you should be very careful with any changes.

    By the way, this question is clearly about development, therefore the category should be Development / Customization / SDK, not Other. I'll fix it for you this time.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,340 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans