Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

The value 0 is not found in map

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

while select  dirpartylocation
        where dirpartylocation.Party == this.OMOperatingUnitID
    notExists join inventLocationLogisticsLocation
        where inventLocationLogisticsLocation.InventLocation == sInventLocation.RecId
    notExists join _logisticspostaladdress
            where inventLocationLogisticsLocation.Location == _logisticspostaladdress.Location
    {
        rolesCon = _rolesMap.lookup(_logisticspostaladdress.Location);
        //Create new location
        newLogisticsLocation = LogisticsLocation::create(LogisticsLocation::find(_logisticspostaladdress.Location).Description);

 

        //Create address
        newPostalAddress.clear();
        newPostalAddress.data(logisticsPostalAddress::findByLocation(_logisticspostaladdress.Location));
        newPostalAddress.Location = newLogisticsLocation.RecId;
        newPostalAddress.insert();

getting the error like "the value 0 is not found in map" in Line 8.

  • Suggested answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: The value 0 is not found in map

    notExists join _logisticspostaladdress means you dont have that table record so why you are using a field from that table

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: The value 0 is not found in map

    Hi mahiims18,

    then you need to fix your code. I have explained why you get the error. Please note that I also updated my previous comment, pointing out that your _logisticsPostalAddress.Location will always be 0 once your code reaches line 8.

    Right now it's not possible to suggest exact fix to your code, there's simply not enough information available.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: The value 0 is not found in map

    Hi Nikolaos

    I have one more statement in my code after line 18.

    i.e newInventLocationLogisticsLocation.addEntityLocation(rolesCon, true);

    so I can't remove line 8.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: The value 0 is not found in map

    Hi mahiims18,

    this error means that your map doesn't contain a value that would correspond to _logisticsPostalAddress.Location key.

    You can use exist method to check whether a value exists in a map, and only call lookup if the value exists. This way you can avoid the error.

    You should also be aware that your code will always result in _logisticsPostalAddress.Location being 0 on line 8, since you don't select any LogisticsPostalAddress. Instead _logisticsPostalAddress is used for notexist join.

    We don't know how you populate _rolesMap, and your code also doesn't show what you do with rolesCon. But based on all the information that you shared, you could just remove line 8 completely. It would not impact how the rest of the (shared) code works.

    docs.microsoft.com/.../gg911868(v=ax.60)

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans