I want to show alert message if any items having location code more than one in item bin content how can be done in Al code?
Yes I wanted this one, thanks now its working.
Then you can use something like this:
codeunit 50100 ItemTools { trigger OnRun() var loaction: Record Location; Item: Record Item; NoOfLocations: Integer; LocationString: Text; BinContect: Record "Bin Content"; begin NoOfLocations := 0; LocationString := ''; Item.SetRange(Blocked, false); If Item.FindSet(false, false) then repeat BinContect.Reset(); BinContect.SetRange("Item No.", Item."No."); if BinContect.Count > 1 then Message('Item No. %1 has %2 related Bin Content records',Item."No.",BinContect.Count); until Item.Next() = 0; end; }
Yes, but I want the code that triggers the message which check each Items that has more than one location code in its item bin content, is it possible we can do that? please do help only for that.
I am still a bit confused around how you actually plan to use this function.
But this code only triggers the message for Items located in more than one location and where Bin's are also used on the location.
codeunit 50100 ItemTools { trigger OnRun() var loaction: Record Location; Item: Record Item; NoOfLocations: Integer; LocationString: Text; begin NoOfLocations := 0; LocationString := ''; Item.SetRange(Blocked, false); If Item.FindSet(false, false) then repeat if loaction.FindSet(false, false) then repeat Item.Setfilter(Item."Location Filter", loaction.Code); Item.SetFilter("Bin Filter", '<>%1', ''); If Item.Inventory > 0 then begin NoOfLocations = 1; if NoOfLocations = 1 then LocationString := loaction.Code; If NoOfLocations > 1 then LocationString := LocationString ' ' loaction.Code; end; until loaction.Next() = 0; if NoOfLocations > 1 then Message('Item %1 is avalible on these %2 locations %3', Item."No.", NoOfLocations, LocationString); until Item.Next() = 0; end; }
In this code I am getting all location code of items which is in bin content but i want only that items which has more than one location code.
procedure loc()
var
Item: Record Item;
Bin: Record "Bin Content";
loaction: Record Location;
NoOfLocations: Integer;
LocationString: Text;
begin
NoOfLocations := 0;
LocationString := '';
Item.SetRange(Blocked, false);
if Item.FindSet() then
repeat
if Bin.FindSet() then
repeat
Item.SetRange("No.", bin."Item No.");
if (bin."Location Code" > Format(1)) then begin
Message('%1', Bin."Location Code");
end;
until Bin.Next() = 0;
until item.Next() = 0;
end;
I needed only those items which has more than one location code(item bin content).
But how are you going to present those data?
In a report ?
And is it the bin that is important or the location or both?
Running through possible hunders or thousands of items and display a message for every items does not seem like a good appoach.
The alert needs to look at the Item Card and then report if there are Items which have more than one Bin Location (Item Bin Content).
so needed solution for this.
Ok thankyou will try and update.
You can try this code where you can send in the item you want to check.
codeunit 50100 ItemTools { procedure CountLocations(Item: Record Item) var loaction: Record Location; NoOfLocations: Integer; LocationString: Text; begin NoOfLocations := 0; LocationString := ''; if loaction.FindSet(false, false) then repeat Item.Setfilter(Item."Location Filter", loaction.Code); Item.CalcFields(Inventory); If Item.Inventory > 0 then begin NoOfLocations = 1; if NoOfLocations = 1 then LocationString := loaction.Code; If NoOfLocations > 1 then LocationString := LocationString ' ' loaction.Code; end; until loaction.Next() = 0; if NoOfLocations >1 then Message('Item %1 is avalible on these %2 locations %3',Item."No.",NoOfLocations,LocationString); end;
YES, so if any item have more than one bin location code then i needed to trigger alert or display message that item has more than one location code.
so needed al code to display that.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156