SBX - Search With Button

SBX - Forum Post Title

How to create an Item Cross Reference using web services

Microsoft Dynamics NAV Forum

ignacio asked a question on 16 Apr 2018 5:19 PM
My Badges

Question Status

Verified

Hi,

I want to create a Bar_Code Item Cross Reference but I got an error that I'm not been able to solve.

This is how I do it.

- Create an entry en Page 5723 "Item Cross References" like:

<ItemCrossReferences>
    <Key>...</Key>
    <Cross_Reference_No>XXXXXX</Cross_Reference_No>
    <Item_No>8011</Item_No>
    <Unit_of_Measure>EACH</Unit_of_Measure>
    <Discontinue_Bar_Code>false</Discontinue_Bar_Code>
</ItemCrossReferences>

This works great.

Now the failing part

- Create an entry in the Page 5721 "Item Cross Reference Entries".

<ItemCrossReference>
    <Key>...</Key>
    <Cross_Reference_Type>Bar_Code</Cross_Reference_Type>
    <Cross_Reference_No>XXXXXX</Cross_Reference_No>
    <Unit_of_Measure>EACH</Unit_of_Measure>
    <Discontinue_Bar_Code>false</Discontinue_Bar_Code>
</ItemCrossReference>

And then I get this error:
System.Web.Services.Protocols.SoapException: 'The Item does not exist. Identification fields and values: No.='''


Any idea of what might be the problem?

I do not see any No. property in the ItemCrossReference class

Thanks,
Ignacio

Reply
Andrey Baludin responded on 17 Apr 2018 2:35 AM
My Badges
Suggested Answer

Hi! You have to pass Item No. for which you create item cross-reference. On Insert trigger has Item.GET() function which throws you an exception:

Reply
ignacio responded on 17 Apr 2018 7:48 AM
My Badges

Hi Andrew,

Thanks for  your answer, unfortunately I cannot see the Item_No field in the schema provided by the web service. This is the description of the ItemCrossReference returned by that page (5721 "Item Cross Reference Entries")

<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="Key" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Cross_Reference_Type" type="tns:Cross_Reference_Type"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Cross_Reference_Type_No" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Cross_Reference_No" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Unit_of_Measure" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Description" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Discontinue_Bar_Code" type="xsd:boolean"/>
</xsd:sequence>
Thanks,
Ignacio
Reply
Andrey Baludin responded on 17 Apr 2018 9:12 AM
My Badges
Verified Answer

You need to add Item No field on page 5721 at NAV to see it in Web Service.

But pages 5721 and 5723 are both based on the same table - Item Cross Reference. Why do you need them both as web services? You can use just 5723 and everything will be ok.

Reply
ignacio responded on 17 Apr 2018 5:13 PM
My Badges

Thanks for your help,

Note for future searches:

This is how you design a page in NAV

stoneridgesoftware.com/dynamics-nav-development-for-non-developers-part-6-adding-a-field-to-a-list-page

Reply
ignacio responded on 17 Apr 2018 6:04 PM
My Badges

Hi,

I have now another issue, as I said I'm creating both a record in both 5721 & 5723 pages. I can create the record in 5723 but when I try it in 5721 I'm getting this error:

The Item Cross Reference already exists. Identification fields and values: Item No.='1006',Variant Code='',Unit of Measure='EACH',Cross-Reference Type=' ',Cross-Reference Type No.='',Cross-Reference No.='XXXXXX1111''

You pointed that both 5721 & 5723 use the same underlying table.

Do I need to create both entries?

I know I'm missing something, because after I create the record in 5723 I can see it when querying the web service, but I do not see the entry in 5721

What I'm missing?

Thanks,

Ignacio

Reply
Andrey Baludin responded on 18 Apr 2018 2:22 AM
My Badges
Suggested Answer

Think about 5721 and 5723 as a 2 interfaces for the same table. Then you create record in 5723 it appears in Item Cross Reference table and you can't create it with 5721 because it already exists (same key). You just need to create it with one of them. not in both.

But it's very strange that you can't see it in 5721. It definitely exists there.

Reply
Andrey Baludin responded on 17 Apr 2018 9:12 AM
My Badges
Verified Answer

You need to add Item No field on page 5721 at NAV to see it in Web Service.

But pages 5721 and 5723 are both based on the same table - Item Cross Reference. Why do you need them both as web services? You can use just 5723 and everything will be ok.

Reply
Andrey Baludin responded on 17 Apr 2018 2:35 AM
My Badges
Suggested Answer

Hi! You have to pass Item No. for which you create item cross-reference. On Insert trigger has Item.GET() function which throws you an exception:

Reply
Andrey Baludin responded on 18 Apr 2018 2:22 AM
My Badges
Suggested Answer

Think about 5721 and 5723 as a 2 interfaces for the same table. Then you create record in 5723 it appears in Item Cross Reference table and you can't create it with 5721 because it already exists (same key). You just need to create it with one of them. not in both.

But it's very strange that you can't see it in 5721. It definitely exists there.

Reply

SBX - Two Col Forum

SBX - Migrated JS