Forums

Forums / Bugs & Issues / Saved Query Session parameter

Saved Query Session parameter

17 posts, 1 answered
  1. Joel Kelner
    Joel Kelner avatar
    3 posts
    Registered:
    19 Jun 2019
    Answered
    18 May 2020
    Link to this post
    I'm seeing an issue when using a session variable as a paramter to a saved query.

    The same session variable can be used successfully by the TPC widgets, but produces an error when used in a saved query.

    The parameter is in the format as specified in the 5.1 release notes.
    @session:{contactid}@

    The call to the webservice returns this error
    {"Detail":"Failed retrieving records: 'Unhandled exception thrown during plugin execution'"}

    From the error logs
    ctivityId: 80000050-000a-fe00-b63f-84710c7967bb

    Timestamp: 5/18/2020 10:04:29 PM

    Message: HandlingInstanceID: 52bc9151-a74d-4b91-811d-b660c05473d3
    An exception of type 'System.Exception' occurred and was caught.
    ----------------------------------------------------------------
    05/18/2020 17:04:29
    Type : System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : Failed retrieving records: 'Unhandled exception thrown during plugin execution'
    Source : pavliks.PortalConnector
    Help link : 
    Data : System.Collections.ListDictionaryInternal
    TargetSite : pavliks.PortalConnector.Services.ServiceInterfaces.SavedQueryResponse #3m(System.String, System.String[])
    HResult : -2146233088
    Stack Trace :    at pavliks.PortalConnector.Services.SavedQueryService.#3m(String , String[] ) in #zkb:line 201
       at pavliks.PortalConnector.Services.SavedQueryService.Execute(String name) in #zkb:line 209
       at SyncInvokeExecute(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

    Additional Info:

    MachineName : UF8897WS72
    TimeStamp : 5/18/2020 10:04:29 PM
    FullName : Telerik.Sitefinity.Utilities, Version=12.2.7200.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
    AppDomainName : /LM/W3SVC/2/ROOT-1-132343126844511834
    ThreadIdentity : 
    WindowsIdentity : WINONA\JHKelner
    Requested URL : https://localhost:44393/SavedQueryService/Execute/todos





  2. Joel Kelner
    Joel Kelner avatar
    3 posts
    Registered:
    19 Jun 2019
    18 May 2020 in reply to Joel Kelner
    Link to this post
    I created a simple contact search fetchxml and got a more descriptive error.

    See below.
    thanks!


    From webservice
    {"Detail":"Failed retrieving records: 'An exception System.FormatException was thrown while trying to convert input value '@session:{contactid}@' to attribute 'contact.contactid'. Expected type of attribute value: System.Guid. Exception raised: Expected {0xdddddddd, etc}.'"}

    Timestamp: 5/18/2020 10:32:27 PM

    Message: HandlingInstanceID: d7635466-d3f4-439f-be67-d9abbd236c18
    An exception of type 'System.Exception' occurred and was caught.
    ----------------------------------------------------------------
    05/18/2020 17:32:27
    Type : System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : Failed retrieving records: 'An exception System.FormatException was thrown while trying to convert input value '@session:{contactid}@' to attribute 'contact.contactid'. Expected type of attribute value: System.Guid. Exception raised: Expected {0xdddddddd, etc}.'
    Source : pavliks.PortalConnector
    Help link : 
    Data : System.Collections.ListDictionaryInternal
    TargetSite : pavliks.PortalConnector.Services.ServiceInterfaces.SavedQueryResponse #3m(System.String, System.String[])
    HResult : -2146233088
    Stack Trace :    at pavliks.PortalConnector.Services.SavedQueryService.#3m(String , String[] ) in #zkb:line 201
       at pavliks.PortalConnector.Services.SavedQueryService.Execute(String name) in #zkb:line 209
       at SyncInvokeExecute(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

    Additional Info:

    MachineName : UF8897WS72
    TimeStamp : 5/18/2020 10:32:27 PM
    FullName : Telerik.Sitefinity.Utilities, Version=12.2.7200.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
    AppDomainName : /LM/W3SVC/2/ROOT-1-132343138058243757
    ThreadIdentity : 
    WindowsIdentity : WINONA\JHKelner
    Requested URL : https://localhost:44393/SavedQueryService/Execute/contact-test


  3. Josh
    Josh avatar
    47 posts
    Registered:
    01 Jun 2018
    15 Jul 2020 in reply to Joel Kelner
    Link to this post
    Hello Joel,

    I believe you are seeing this error because you are not using the correct format for the session variable. I believe you need to remove the { and } around the name of the Session variable. Below is an example of using the session variable in a Saved Query with the first part being the GUID string being added to the session, and the second part being the FetchXML.

    Session["TestSession"] = "99e7f3d2-0f63-ea11-a811-000d3af45a96";

    <fetch version="1.0" mapping="logical" output-format="xml-platform">
      <entity name="contact">
        <attribute name="contactid" />
        <attribute name="address1_city" />
        <filter type="and">
          <condition attribute="contactid" operator="eq" value="@session:TestSession@" />
        </filter>
        <link-entity name="account" alias="contactdf5" to="parentcustomerid" from="accountid">
          <attribute name="name" />
          <attribute name="emailaddress1" />
        </link-entity>
      </entity>
    </fetch>

    Please give that a shot and if the problem persists reach out to support@crmportalconnector.com to troubleshoot further!

    Cheers,

    Josh
  4. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    10 Aug 2022 in reply to Josh
    Link to this post
    How to add a Session Variable from the sitefinity?
  5. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    10 Aug 2022 in reply to Priyanka Sharma
    Link to this post
    Hello Priyanka,

    Are you asking how to create a session a variable?

    All the best,

    Brady
    TPC Web Developer
  6. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    11 Aug 2022 in reply to Brady Ward
    Link to this post
    Yes like I want to use a same guid value in different pages, so how can I assign it to a session variable to act like a global in the Portal.
  7. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    11 Aug 2022 in reply to Priyanka Sharma
    Link to this post
    Hello Priyanka,

    Understood - keep in mind, the session variables are stored per user session, so you would have to make sure this variable is getting set when a user visits your site or at least the specific page.

    Here is some documentation about how session variables work within an ASP.NET application: https://docs.microsoft.com/en-us/previous-versions/aspnet/ms178581(v=vs.100)

    What exactly are you trying to accomplish with the global GUID?

    All the best,

    Brady
    TPC Web Developer
  8. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    11 Aug 2022 in reply to Brady Ward
    Link to this post
    I want to pass this to the form id for a custom entity. I am able to pass it in url in one page but unable to figure out to propagate in further pages navigation. Please help me in this.
    Thank you!
  9. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    11 Aug 2022 in reply to Priyanka Sharma
    Link to this post
    Hello Priyanka,

    How are you navigating users from one page to the next?

    All the best,

    Brady
    TPC Web Developer
  10. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    11 Aug 2022 in reply to Brady Ward
    Link to this post
    Through the navigation links.
  11. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    11 Aug 2022 in reply to Priyanka Sharma
    Link to this post
    The navigation links as in any link on the page or are you using a form flow navigation?

    All the best,

    Brady
    TPC Web Developer
  12. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    11 Aug 2022 in reply to Brady Ward
    Link to this post
    Link on the Page.
  13. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    11 Aug 2022 in reply to Priyanka Sharma
    Link to this post
    Could you possibly use JavaScript to pull the ID from the URL and append it to the href on each subsequent page?

    ie. Check if the query string exists and if it does, pull it and update the anchor tag's href property

    const searchParams = new URLSearchParams(paramsString);
    if(searchParams.has('yourGuidHere')) $("#myAnchorTagId").attr("href", $("#myAnchorTagId").attr("href") + searchParams.get('yourGuidHere');

    Let me know if that helps,

    Brady
    TPC Web Developer
  14. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    11 Aug 2022 in reply to Brady Ward
    Link to this post
    This is a nice solution but the anchor is actually a navigation widget used so no id defined but only classes.
  15. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    11 Aug 2022 in reply to Priyanka Sharma
    Link to this post
    Ah, you can try this:

    for (let anchorTag of $("a")) {
      if (anchorTag.href.includes("/path/to/desired/page")) {
        anchorTag.href = anchorTag.href + searchParams.get("yourGuidHere");
        break; // or return;
      }
    }

    Not the most elegant solution as this will attempt to loop through every anchor tag on the page. You could narrow the results by using the class name of the Navigation widget's anchor tags (so you only return those ones).

    Let me know if that works,

    Brady
    TPC Web Developer
  16. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    11 Aug 2022 in reply to Brady Ward
    Link to this post
    It worked..... :) Thanks alot.
  17. Priyanka Sharma
    Priyanka Sharma avatar
    17 posts
    Registered:
    07 Jul 2022
    12 Aug 2022 in reply to Brady Ward
    Link to this post
    Hi Brady, this is not working actually if we go to some other page and navigate back on this page which need guid.  Is there any global variable definition option?
17 posts, 1 answered