Applying Filter on ReadMultiple - Webservice call from NAV

valanrvalanr Member Posts: 22
Hi All,

I am trying to call a service directly through NAV.
The service will pull all the items using "ReadMultiple" Method .
Now i need to introduce a new Filter like "Inventory <> 0".

Can anyone please suggest the syntax ?

The Codes are :

IF ISCLEAR(Connector) THEN
CREATE(Connector);

//Connector.Property('ProxyServer','isaserver');
//Connector.Property('ProxyPassword','proxypass');
//Connector.Property('ProxyUser','username');

Connector.Property('EndPointURL','http://localhost:7047/DynamicsNAV/WS/CRONUS India Ltd./Page/Item');
Connector.Connect;
Connector.Property('SoapAction','urn:microsoft-dynamics-schemas/page/Item');
Connector.BeginMessage;

CREATE(Serializer);
Serializer.Init(Connector.InputStream);
Serializer.StartEnvelope('','STANDARD','utf-16');
Serializer.StartBody('STANDARD');
Serializer.StartElement('ReadMultiple','urn:microsoft-dynamics-schemas/page/Item');
:?: :?: :?: :?: :?: :?: :?:
Serializer.EndElement;
Serializer.EndBody;
Serializer.EndEnvelope;

Connector.EndMessage;

IF ISCLEAR(XMLDOM) THEN
CREATE(XMLDOM);
XMLDOM.load(Connector.OutputStream);

XMLNode := XMLDOM.selectSingleNode('//valid');

IF NOT ISCLEAR(XMLNode) THEN
MESSAGE(XMLNode.text);
XMLDOM.save('c:\Item.xml');
CLEAR(XMLDOM);
CLEAR(Connector);

Comments

  • kinekine Member Posts: 12,562
    Example of the request>
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <ReadMultiple xmlns="urn:microsoft-dynamics-schemas/page/customer">
      <filter>
        <Field>City</Field>
        <Criteria>P*</Criteria>
      </filter>
      <filter>
        <Field>Name</Field>
        <Criteria>P*</Criteria>
      </filter>
      <bookmarkKey />
      <setSize>1000</setSize>
      </ReadMultiple>
    </soap:Body>
    </soap:Envelope>
    

    Catched by Fiddler web debugger and one easy application consuming the webservice done in Visual Studio.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • valanrvalanr Member Posts: 22
    Thanks Kine

    Is it possible to incorporate the "filter" using the NAV code?

    I have tried with this code,Its not working

    Serializer.SoapAttribute('Item_Filter','urn:microsoft-dynamics-schemas/page/Item');
    Serializer.SoapAttribute('Field','Blocked');
    Serializer.SoapAttribute('Criteria','No');

    Pls Suggest.

    Regards

    Valan
  • kinekine Member Posts: 12,562
    It is not attribute, it is element....
    Serializer.StartElement('filter');
      Serializer.StartElement('Field');
        Serializer.WriteString('City');
      Serializer.EndElement;
      Serializer.StartElement('Criteria');
        Serializer.WriteString('P*');
      Serializer.EndElement;
    Serializer.EndElement;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • valanrvalanr Member Posts: 22
    Hi Kimil

    Thanks for your reply.
    The filteration for a specific "Card"(100) needs to be acheived through this code,instead its taking all the data :?:

    Pls correct me if i wrong.


    IF ISCLEAR(Connector) THEN
    CREATE(Connector);
    //Connector.Property('ProxyServer','isaserver');
    //Connector.Property('ProxyPassword','proxypass');
    //Connector.Property('ProxyUser','username');
    Connector.Property('EndPointURL','http://localhost:7047/DynamicsNAV/WS/CRONUS India Ltd./Page/Loyalty');
    Connector.Connect;
    Connector.Property('SoapAction','urn:microsoft-dynamics-schemas/page/loyalty');
    Connector.BeginMessage;
    CREATE(Serializer);
    Serializer.Init(Connector.InputStream);
    Serializer.StartEnvelope('','STANDARD','utf-16');
    Serializer.StartBody('STANDARD');
    Serializer.StartElement('ReadMultiple','urn:microsoft-dynamics-schemas/page/loyalty');
    Serializer.StartElement('filter');
    Serializer.StartElement('Field');
    Serializer.WriteString('Card');
    Serializer.EndElement;
    Serializer.StartElement('Criteria');
    Serializer.WriteString('100');
    Serializer.EndElement;
    Serializer.EndElement;
    Serializer.StartElement('bookmarkKey');
    Serializer.WriteString('NULL');
    Serializer.EndElement;
    Serializer.StartElement('setSize');
    Serializer.WriteString('1000');
    Serializer.EndElement;
    Serializer.EndElement;
    Serializer.EndBody;
    Serializer.EndEnvelope;
    Connector.EndMessage;

    IF ISCLEAR(XMLDOM) THEN
    CREATE(XMLDOM);
    XMLDOM.load(Connector.OutputStream);
    XMLNode := XMLDOM.selectSingleNode('//valid');

    IF NOT ISCLEAR(XMLNode) THEN
    MESSAGE(XMLNode.text);
    XMLDOM.save('c:\Loyal.xml');
    CLEAR(XMLDOM);
    CLEAR(Connector);
  • kinekine Member Posts: 12,562
    Is Card name of the field?

    And try to use the namespace for all elements...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • valanrvalanr Member Posts: 22
    Hi

    Got the solution,

    I have included the "'urn:microsoft-dynamics-schemas/page/loyalty'" in all the elements.

    Thanks for your valuable input

    \:D/

    Regards

    Valan
Sign In or Register to comment.