This discussion is archived
8 Replies Latest reply: Nov 22, 2012 3:03 AM by 665735 RSS

Error while accessing App_Session in javascript.

665735 Newbie
Currently Being Moderated
Hi All,

I had wrote a Jquery function, before fetching the data from applciation iam trying to check the APP_Session variable but syntax is the problem could you please help me
how we can resolve the problem.
-- 
<script type="text/javascript">
$( function() {
    
    $("#P1_ENG_PART1").autocomplete({
        source : function( request , response) { 
                        data = getJParticipant(request.term);
                        response( data );
                 } ,
        focus  : function(event , ui){
                    event.preventDefault();
                 }
 
    });
});
 
function getJParticipant(key)
{ 
   // Here i want to check the App_session logic code and hence i had implmented which is not working.
       Can any one help me how we can resolve the below problem. 

     if (&APP_SESSION.) is not null then 

      var ajaxRequest = new htmldb_Get( null , '&APP_ID.' , 'APPLICATION_PROCESS=GET_JPARTICIPANT' , 0);
   ajaxRequest.add( 'G_MX01' , key);
   ajaxResult = ajaxRequest.get(); 
   
   return ((ajaxResult.length>0)? ajaxResult.split( '~' ):null);
end if;
 
}
</script>
Thanks,
Anoo..
  • 1. Re: Error while accessing App_Session in javascript.
    Jitendra Pro
    Currently Being Moderated
    Hi Anoo,

    you can use app_id,page id ,session in javascript function,see the code given below
    $v('pFlowId') // APP_ID
    $v('pFlowStepId') // APP_PAGE_ID
    $v('pInstance') // SESSION
    Edited your code, try it.
    <script type="text/javascript">
    $( function() {
        
        $("#P1_ENG_PART1").autocomplete({
            source : function( request , response) { 
                            data = getJParticipant(request.term);
                            response( data );
                     } ,
            focus  : function(event , ui){
                        event.preventDefault();
                     }
     
        });
    });
     
    function getJParticipant(key)
    { 
       // Here i want to check the App_session logic code and hence i had implmented which is not working.
           Can any one help me how we can resolve the below problem. 
     
         if ($v('pInstance')) is not null then 
     
          var ajaxRequest = new htmldb_Get( null , '&APP_ID.' , 'APPLICATION_PROCESS=GET_JPARTICIPANT' , 0);
       ajaxRequest.add( 'G_MX01' , key);
       ajaxResult = ajaxRequest.get(); 
       
       return ((ajaxResult.length>0)? ajaxResult.split( '~' ):null);
    end if;
     
    }
    </script>
    Regards,
    Jitendra
  • 2. Re: Error while accessing App_Session in javascript.
    665735 Newbie
    Currently Being Moderated
    Thanks Jitendra for a quick turn around, Using the below syntax Java script error went but auto complete functionality is not working.
    Did i kept the condition is right place or we need to keep in some other place to filter the autocomplete functionlity.
    Could you please help me here

    Thanks,
    Anoo..
  • 3. Re: Error while accessing App_Session in javascript.
    Jitendra Pro
    Currently Being Moderated
    Hi Anoo,

    enclose autocomlete code between
    $(document).ready( function() {
      // your code
    });
    Or see the link given below for Jquery autocomplete

    http://tylermuth.wordpress.com/2010/03/16/jquery-autocomplete-for-apex/


    Regards,
    Jitendra
  • 4. Re: Error while accessing App_Session in javascript.
    665735 Newbie
    Currently Being Moderated
    Thanks Jitendra i had tried your suggestion which is not up to the mark. Even though i had tried other ways insted of javas script i had made changes to Application process but no luck.


    Thanks,
    Anoo..
  • 5. Re: Error while accessing App_Session in javascript.
    Sc0tt Expert
    Currently Being Moderated
    if ($v('pInstance')) is not null
    That is not valid javascript - looks more like SQL.

    You'll get a session automatically, so I don't necessarily see the point in checking if you have one. I'd take out that whole IF statement.
    var ajaxRequest = new htmldb_Get( null , '&APP_ID.' , 'APPLICATION_PROCESS=GET_JPARTICIPANT' , 0);
    This line needs to change to:
    var ajaxRequest = new htmldb_Get( null , $v('pInstance') , 'APPLICATION_PROCESS=GET_JPARTICIPANT' , 0);
    I think that hopefully should work.
  • 6. Re: Error while accessing App_Session in javascript.
    Jitendra Pro
    Currently Being Moderated
    Hi Anoo,

    your condition is not a valid javascript highlighted above by Sc0tt,it is similar to sql.
    Thanks Sc0tt.


    Anoo you should try this
    function getJParticipant(key)
    { 
       // Here i want to check the App_session logic code and hence i had implmented which is not working.
           Can any one help me how we can resolve the below problem. 
     
         if ($v('pInstance') == '')
         {
     
          var ajaxRequest = new htmldb_Get(null,html_GetElement('pFlowId').value, 'APPLICATION_PROCESS=GET_JPARTICIPANT' , 0);
       ajaxRequest.add( 'G_MX01' , key);
       ajaxResult = ajaxRequest.get(); 
       
       return ((ajaxResult.length>0)? ajaxResult.split( '~' ):null);
        }
     
    }
    Hope this will helps you,

    Regards,
    Jitendra
  • 7. Re: Error while accessing App_Session in javascript.
    665735 Newbie
    Currently Being Moderated
    Hi Scott/Jitinder,

    Thanks for both of you for correcting me syntax error which is working now. But the problem what i have and solution what i had tought was not up to the mark.
    The reason i had not informed initally is that i was totally confidient that it will work for me by uisng this session solution but agian bad luck for me.
    Could you please help me how we can resolve the problem.
    --
    I have a main form in which we have a button when the user clicks on that button a popup screen will be triggred.
    Now by mistake if the users sign-off from the main form and popup will be reatined during that time when they try to enter a autocomplete the we are getting the below error 
    
    Redirecting to the Login Server for authentication...
    <HTML><BODY onLoad="document.LoginForm.submit();">
    
    Since the reason is the form is already got sign-off and which is causing the problem, so i tought it will work by using the session concept but again bad luck for me.
    It will be great if you can help me on this.
    Thanks,
    Anoo..

    Edited by: Anoo on Nov 20, 2012 5:53 AM

    Edited by: Anoo on Nov 20, 2012 6:05 AM
  • 8. Re: Error while accessing App_Session in javascript.
    665735 Newbie
    Currently Being Moderated
    Hi Scott,

    I am back today and trying the concept of implemtaing session as per the suggestion. When i had tried agian in my real time application it was not wroking as expected.
    Not sure what could be the problem and when i had try to implemnet the same in my dummy version it was stopped working too..

    I am sure that i have not made any changes only the new changes which you have suggested me.
    Any suggestion on Redirecting the server...

    Thanks,
    Anoo..

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points