InfoPath 2013 - Null values passed to a stored procedure - InfoPath Dev
in

InfoPath Dev

InfoPath 2013 - Null values passed to a stored procedure

Last post 05-18-2016 09:18 AM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-10-2016 03:43 AM

    • HelenR
    • Not Ranked
    • Joined on 05-10-2016
    • Posts 1

    InfoPath 2013 - Null values passed to a stored procedure

    Hi!


    I have created a repeating table in InfoPath 2013 which looks like the following:


    Id   Cancel   Cancelled reason
    1   Cancel button  Text box
    2   Cancel button  Text box


    When the user clicks on the ‘Cancel’ button a SQL stored procedure is called. The stored procedure requires two parameters, the ID of the record and the cancelled reason (which the user will enter in the text box).


    This is the C# code behind the button:


    public void CTRL110_5_Clicked(object sender, ClickedEventArgs e)
    {
    XPathNavigator dom = MainDataSource.CreateNavigator();
    string cancelledreason = dom.SelectSingleNode(
    "/dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:CancelledReason", NamespaceManager).Value;


    XPathNavigator dom2 = MainDataSource.CreateNavigator();
    string RId = dom2.SelectSingleNode(
    "/dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:RId ", NamespaceManager).Value;


    AdoQueryConnection connection = (AdoQueryConnection)DataConnections["conn"];


    string userName = null;
    SPClaimProviderManager mgr = SPClaimProviderManager.Local;
    if (mgr != null)
    {
    userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
    }


    string originalCommand = connection.Command;


    connection.Command = "EXEC SP_Cancel '" + cancelledreason + " - " + userName + "'," + "'" + RId + "'";
    connection.Execute();


    connection.Command = originalCommand;
    }


    When I click on the cancel button a value of null is only available for cancelledreason and RId.


    Please can you assist with helping me resolve it?


    Cheers,
    Helen

  • 05-18-2016 09:18 AM In reply to

    Re: InfoPath 2013 - Null values passed to a stored procedure

     So - the button is inside the repeating table? You want to use e.Source to select the current repeating node.

    https://msdn.microsoft.com/EN-US/library/microsoft.office.infopath.clickedeventargs.source.aspx

    Probably:

    string cancelledreason = e.Source.SelectSingleNode("ns1:CancelledReason", NamespaceManager).Value;  

     

    Hilary Stoupa

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.