Problem changing a value from secondary data source - InfoPath Dev
in

InfoPath Dev

Problem changing a value from secondary data source

Last post 10-11-2007 04:29 AM by adamrharding. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 10-02-2007 01:31 AM

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Problem changing a value from secondary data source

    Hi, I'm trying to change a value from a secondary data source ("Articulos"). I have tried it with some code I made:

     function msoxd_my_cantidad::OnAfterChange(eventObj)
    {
        var cantidad = XDocument.DOM.selectSingleNode("/inv:invoice/my:Bloque/my:Pago/my:datos/my:cantidad");
        var DOM_Articulo = XDocument.GetDOM("Articulos");
        var ID_Articulo = XDocument.DOM.selectSingleNode("/inv:invoice/my:Bloque/my:Pago/my:datos/my:ID_Articulo");
        var StockVirtual = DOM_Articulo.selectSingleNode("/myFields/dataFields/Articulos/Stock_virtual[../@ID = ID_Articulo]");
        
        if (eventObj.NewValue > eventObj.OldValue)
            {
                StockVirtual = StockVirtual + (eventObj.NewValue -1)
        }else{
                if (eventObj.NewValue < eventObj.OldValue)
                    {
                        StockVirtual = StockVirtual + (eventObj.OldValue - eventObj.NewValue)
                    }
            }
    }

     

    But it doesn't work.

     

    My question is: is that code ok? Is there another way to change a value from a secondary data source?

     

    Thanks. 

     

  • 10-03-2007 12:39 AM In reply to

    Re: Problem changing a value from secondary data source

    Hi GLazkano,

    This is because you have not defined the namespaces that exist on your secondary DOM. I think this blog post should point you in the right direction: http://www.infopathdev.com/blogs/matt/archive/2006/02/02/Setup-Namespaces-for-a-Secondary-Data-Source.aspx

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-03-2007 02:03 AM In reply to

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Re: Problem changing a value from secondary data source

     Hi Matt,

    Thanks for your reply. I read that blog post and finally that 'dfs' namespace is not a problem. But now I have still a problem. I'm sure it may be some stupid detail or something. but I cant fix it.

    Now the code looks like:

     var DOM_Articulo = XDocument.GetDOM("Articulos");
     var ID_Articulo = XDocument.DOM.selectSingleNode("/inv:invoice/my:Bloque/my:Pago/my:datos/my:ID_Articulo");
     var StockVirtual = DOM_Articulo.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Articulos/@Stock_virtual[../@ID = ID_Articulo]").text;

     But in the preview it fails with message: An object is required. Fails on the 3rd row ( var StockVirtual = DOM_Articulo.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Articulos/@Stock_virtual[../@ID = ID_Articulo]").text; -> this row).

     
    I don't know what fails. Can anyone tell me what is the problem?

     

  • 10-03-2007 08:28 AM In reply to

    Re: Problem changing a value from secondary data source

    Yup, it's in the details.  Try this:

      var StockVirtual = DOM_Articulo.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Articulos/@d:Stock_virtual[../@d:ID = '" + ID_Articulo + "' ]").text;

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-03-2007 08:37 AM In reply to

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Re: Problem changing a value from secondary data source

     Well, I tried it (with a few changes, my XPath hasn't any 'd:' namespace) and now it says that an object is required. The sentence is now:

    var StockVirtual = DOM_Articulo.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Articulos/Stock_virtual[../@ID = '" + ID_Articulo + "' ]").text;

    I can't understand why it isn't working! 

     

  • 10-03-2007 09:04 AM In reply to

    Re: Problem changing a value from secondary data source

    This is probably too generic and does not provide a precise enough address, but it's worth a shot.  Maybe it will narrow down the problem.

    var StockVirtual = DOM_Articulo.selectSingleNode("//Stock_virtual[../@ID = '" + ID_Articulo + "' ]").text;

     

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-03-2007 09:13 AM In reply to

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Re: Problem changing a value from secondary data source

     Thanks but it does the same: An object is required.

     If you need additional data: that secondary datasource is shared from a sharepoint library and in other part of the code, I queried the DS and I get the value, but that value wasn't linked to the DS, was only on a text box and if I change it's value it wasn't updated on his DS.
     

  • 10-10-2007 01:18 AM In reply to

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Re: Problem changing a value from secondary data source

    Hi again!

    I continue with the same problem and my project must be finished this next week.

    Please, does anyone know how to solve it?


     

  • 10-10-2007 04:29 AM In reply to

    Re: Problem changing a value from secondary data source

    Hi

    The only way to do this without a whole lot of coding is to look a Qdabras Database Accelerator that would allow you to update secondary data sources natively.

    You are in some complicated code there and if you need a very quick result then the above is your best chance.

    Cheers Adam

    Adam Harding
    Wales
    UK
  • 10-10-2007 06:56 AM In reply to

    Re: Problem changing a value from secondary data source

    Hi GLazkano,

     I think this is a simple XPath error, but it is hard to debug without your form.  Is there anyway you could attach it to your next reply so that I can look at it more in-depth?

    Adam, could you explain how DBXL would help in this scenario?  I'm not seeing the connection.

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-10-2007 07:40 AM In reply to

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Re: Problem changing a value from secondary data source

    Hi again!

    Thanks Adam and Matt. I've downloaded that DBXL application but first I will try to explain you with an explicative picture and with my form what's happening.

     Free Image Hosting at www.ImageShack.us

    In that picture there is 2 different squares: the red one is for search a product. Once that product is found, the blue one receives the value of 1, because by default that is the quantity of a product. That quantity must be substracted from a stock field in a secondary data source (that secondary data source is where the articles are stored). And if anyone changes that value (you can need 10 of the same product) that value must change on that field in the secondary data source .

     I don't know if I'm explaining myself, but I think it's enough to understand my problem

    PS: My form is too big for attaching it here, so I uploaded it to megaupload, here is the link http://www.megaupload.com/es/?d=PYDN3A7P

  • 10-10-2007 11:40 AM In reply to

    Re: Problem changing a value from secondary data source

    Hi Matt My theory about DBXL (excuse me if my understanding is a little woolly) is that you could use the service to modify the data on route to the form. If I am in error I apologise profusely and will duly beg the forgiveness of Glazkano. Sorry if I have misunderstood
    Adam Harding
    Wales
    UK
  • 10-11-2007 01:54 AM In reply to

    Re: Problem changing a value from secondary data source

    Hi Glazkano,

    I think this is an xpath issue which is good news because it should be a relatively simple fix, but xpath can be tricky. Greg might be best person to ask. If you need some help this week, please purchase some support credits and we'll allocate some time Friday to debug this with you in real time.

    Hi Adam,

    Thanks for the creative imagination,but I don't think DBXL would be required for Glazkano's scenario. The main value prop of DBXL is to help people integrate InfoPath with their SQL database (without writing code). Glazkano's form just has a problem with the secondary data source so should just be a straightforward xpath issue.

     Cheers!

    Patrick Halstead
    Project Manager at Qdabra
  • 10-11-2007 02:13 AM In reply to

    • GLazkano
    • Top 200 Contributor
      Female
    • Joined on 07-05-2007
    • Basque Country
    • Posts 54

    Re: Problem changing a value from secondary data source

    Hi Patrick!

    When you say purchase, I understand pay for that help (maybe because my english is bad). But if you mean that: how many costes that help and who must I talk with?

     Thanks.
     

  • 10-11-2007 03:17 AM In reply to

    Re: Problem changing a value from secondary data source

    Hi Gorka,

    I replied separately in e-mail.

    Cheers!

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 2 (16 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.