Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Display A Dialog box Xbasic during ajax call back

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display A Dialog box Xbasic during ajax call back

    Hello,

    I have an ajax call back that run as expected being called from a button, in the ajax call back i want it to display the result of rs.data(1) in a message box to the user that will then run another call back depending if the user selects YES. This callback works fine but I want to add a prompt showing the user what data it found before performing the next sql statement. Ive seen a lot of posts about using a5.messageBox.Show() but not sure how to use it. Here's what ive constructed so far:
    Code:
    function FindPreviousEvaluation as c ( e as p)
    
    	'Find Previous eval if it exists, and update current record
    	debug(1)
    	dim cn as sql::Connection
    	dim args as sql::Arguments
    	dim sqlUPDATE as c
    	dim EvalCount as n
    	dim rs as sql::resultset
    
    	args.set("arg0", e.dataSubmitted.EVALUATION_YEAR)
    	args.set("arg1", e.dataSubmitted.StaffID)
    	
    	flag = cn.open("::Name::StaffDB")
    		If flag = .f. then
    			FindPreviousEvaluation = "alert('Could Not Establish Connection');"
    		else
    			sql =	<<%sql%
    			SELECT MAX(EVALUATION_YEAR) AS PreviousEval
    			FROM evaluations_mgrs
    			WHERE STAFF_ID_FK = :arg1 AND EVALUATION_YEAR <> :arg0
    			%sql%
    			
    			cn.execute(sql, args)
    			rs = cn.resultSet
    			PreviousEvalYear = rs.data(1)
    			args.set("arg2", PreviousEvalYear)
    			cn.freeresult()
    			
    			If PreviousEvalYear = "" then
    				'Tell user no previous evaluation exists
    				FindPreviousEvaluation = "alert('No Previous Evaluation Exists.');"
    			else
    'THIS IS WHERE I NEED HELP				
    				'Display a prompt for the user asking how to proceed
    				'show message box as: "Last Eval year found: rs.data(1) that I previously placed in a variable -> {PreviousEvalYear}"
    				'Do you want to proceed? Yes button, Cancel button
    				'If "Yes button" = .t. then
    					sqlUPDATE = <<%sql%
    					UPDATE evaluations_mgrs t1 
    					INNER JOIN evaluations_mgrs t2 ON (t1.STAFF_ID_FK=:arg1 AND t2.STAFF_ID_FK=:arg1) 
    					SET t1.PREVIOUS_OVERVIEW = t2.CURRENT_OVERVIEW, 
    					t1.PREVIOUS_GOALS = t2.CURRENT_GOALS, 
    					t1.PREVIOUS_FOCUS = t2.CURRENT_FOCUS, 
    					t1.PREVIOUS_STRENGTHS = t2.CURRENT_OVERVIEW, 
    					t1.PREVIOUS_AREAS_OF_IMPROVEMENTS = t2.CURRENT_AREAS_OF_IMPROVEMENT, 
    					t1.PREVIOUS_INCIDENTS = t2.CURRENT_INCIDENTS, 
    					t1.PREVIOUS_ACCOMPLISHMENTS = t2.CURRENT_ACCOMPLISHMENTS 
    					WHERE t1.EVALUATION_YEAR = :arg0 AND t2.EVALUATION_YEAR=:arg2
    					%sql%
    					flag = cn.Execute(sqlUPDATE, args)
    				'else do nothing
    'HOW DO I ACCOMPLISH THIS				
    				end if
    			end if
    		end if
    	cn.Close()
    
    end function

  • #2
    Re: Display A Dialog box Xbasic during ajax call back

    You can't interrupt a callback... so just split it up. If you need to do the 2nd part, then send control back to the client... ask your question... and then run another callback.

    You could run the same callback and put in code to test what stage you're at. The example attached uses 2 callbacks.
    Attached Files

    Comment


    • #3
      Re: Display A Dialog box Xbasic during ajax call back

      Thank you for the reply David,

      Maybe I am doing something wrong but when i try to add the file you attached into my web projects, it displays the component type as "Unknown", and when I open it, it is completely empty?

      I've tried adding it using the "Add File" button in alpha and also tried simply dragging and dropping the file into the web projects folder directly.

      Comment


      • #4
        Re: Display A Dialog box Xbasic during ajax call back

        Try this one. What Version and Build of Alpha are you using?
        Attached Files

        Comment


        • #5
          Re: Display A Dialog box Xbasic during ajax call back

          Well it took a while for me to comprehend what was going on and how you set this up and ive got to say... Wow! I'ts not as simple as I originally thought. Correct me if Im wrong here but this is how I understand it working:

          1. When button is pressed it performs an ajax call back that performs the "Find previous Eval".
          2. If it does not find a previous eval it informs the user that no record was found with a simple alert().
          3. If it does find a record, it performs a defined JavaScript function.
          4. The defined JavaScript function defines the xbasic dimmed var found by the callBack by using "askFindPrevEval('" + PreviousEvalYear + "');".
          5. Once the Defined Javascript function runs it then prompts the user with the record that it found.
          6. Depending on what the user selects (Yes, No, Cancel) it will perform another defined ajax callback to update the current record, or simply close the dialog and do nothing.

          I think thats about right... Right?

          Comment


          • #6
            Re: Display A Dialog box Xbasic during ajax call back

            Yup... you got it.

            You need info from the server... so you go get it.
            Based on what you find at the server, you send that info back to the user and ask if they want to do something with it.
            If they say Yes then you go back to the server to finish up.

            I'm not sure what you've written in #4. XBasic can return anything back to the client. In this case you're simply calling a javascript function. That function call, just the call, is built in XBasic and includes a parameter. The client-side gets the function call, and executes it. It's just a string returned to the client... and, essentially, Alpha knows what to do with it. The javascript function doesn't define an xbasic dimmed var... it just processes the parameter.

            You've not mentioned what Alpha version you're working with, but I believe the issue you had with the component concerns the UX property "Save component format" - which I had set to "formatted JSON" and your version of Alpha didn't understand. So I changed it to Binary and re-posted.

            Comment


            • #7
              Re: Display A Dialog box Xbasic during ajax call back

              #4, yes I meant that xbasic passed the parameter to the javascript function by using askFindPrevEval('" + PreviousEvalYear + "');. Because xbasic defined the value of "PreviousEvalYear", and then javascript could see the value by using askFindPrevEval('" + PreviousEvalYear + "');... Right?

              I've never used JSON nor do I know how it can be used, I'm still struggling to understand Xbasic and JavaScript. Im using version 12.3 Build 2999-4519.

              Comment


              • #8
                Re: Display A Dialog box Xbasic during ajax call back

                Yes... exactly.

                And... your version makes sense as well... I don't think that UX property was available in 2999. You should mention up front in your post what version you're working with. 2999 is more than a year old.

                Comment


                • #9
                  Re: Display A Dialog box Xbasic during ajax call back

                  Thank you for the advice, I will make sure to note that on my next post.

                  Is it possible to pass more than one parameter? Say, if i wanted to pass the evaluation year and the ID of the record? Would that look like this:

                  askFindPrevEval('" + PreviousEvalYear + "+" + RecordID + "');

                  Comment


                  • #10
                    Re: Display A Dialog box Xbasic during ajax call back

                    Yes... but you must follow the pretty much universal format for supplying params...

                    Code:
                    askFindPrevEval('" + PreviousEvalYear + "," + RecordID + "');
                    And then, of course, change your js function to accept the 2nd param...

                    Code:
                    function askFindPrevEval(PreviousEvalYear,recordId){
                    and I really should make a small cosmetic correction. On the Javascript side... case matters... and it's kinda common to use camelCase. So the Javascript function should be...

                    Code:
                    function askFindPrevEval(previousEvalYear,recordId){
                    
                    	var _msg = 'Last Eval year found: '+previousEvalYear+'.<br>Do you want to proceed?';
                    	A5.msgBox.show('Previous Eval Year',_msg,'ync',function(button){
                    	    if(button == 'yes'){
                    		    {dialog.Object}.ajaxCallback('','','FindPrevEvalContinue','','__prevEvalYear='+previousEvalYear);
                    	    }else{
                    	        // nothing to do
                    	    }
                    	});
                    
                    }
                    The change is just the lowercase 'p' on the param 'previousEvalYear'... used throughout the function.

                    Comment


                    • #11
                      Re: Display A Dialog box Xbasic during ajax call back

                      Thank you David, youve been very helpful... Ive learned a lot

                      Comment


                      • #12
                        Re: Display A Dialog box Xbasic during ajax call back

                        Hello again, I am trying to pass two varibales to the JS prompt but its not coming up properly. here is part of my xbasic code:
                        Code:
                        IF e.dataSubmitted.FK_PTO_TYPE_ID = "1" .OR. e.dataSubmitted.FK_PTO_TYPE_ID = "2" then
                        			dim cn as sql::Connection
                        			dim args as sql::Arguments
                        			dim sqlSELECT as c
                        			dim rs as sql::ResultSet
                        			dim PunchCount as n
                        			'-----------------------------------------------
                        			'Check to how much Time-off Emplyee is alotted
                        			'-----------------------------------------------
                        			flag = cn.open("::Name::StaffDB")
                        			args.set("EmployeeID", e.dataSubmitted.argEMPLOYEE_ID)
                        			sqlSELECT = <<%sql%
                        			SELECT
                        			timeoff_vacation,
                        			timeoff_personal
                        			FROM staff
                        			WHERE staff_id = :EmployeeID
                        			%sql%
                        			flag = cn.Execute(sqlSELECT, args)
                        			rs = cn.ResultSet
                        			VacationAlotted = rs.data(1)
                        			PersonalAlotted = rs.data(2)
                        			cn.FreeResult()
                        			IF e.dataSubmitted.FK_PTO_TYPE_ID = "1" then
                        				'-----------------------------------------------
                        				'Check to how much VACATION Time-off Emplyee has used
                        				'-----------------------------------------------
                        				flag = cn.open("::Name::FINANCIAL")
                        				args.set("EmployeeID", e.dataSubmitted.argEMPLOYEE_ID)
                        				args.set("TodaysYear", e.dataSubmitted.argYear)
                        				sqlSELECT = <<%sql%
                        				SELECT COALESCE(SUM(t2.pto_hrs),0) as VacationUsed
                        				FROM  timesheets t1
                        				LEFT JOIN timesheets_pto t2 
                        							ON t1.pk_timesheet_id = t2.fk_timesheets_id
                        				WHERE t1.FK_STAFF_ID = :EmployeeID 
                        						AND t2.FK_PTO_TYPE_ID = 1 
                        						AND YEAR(t1.TODAYSDATE) = :TodaysYear
                        				%sql%
                        				flag = cn.Execute(sqlSELECT, args)
                        				rs = cn.ResultSet
                        				VacationUsed1 = rs.data(1)
                        				cn.FreeResult()
                        				'---------------------------------------------------------------------------------------
                        				'VacationUsed1 is in hours, need to convert to Days, Vacation1 Divided by 8 = #of Days
                        				'---------------------------------------------------------------------------------------
                        				VacationUsed = (VacationUsed1 / 8)
                        				'------------------------------------------------------------------
                        				'Show user a prompt with Vacation alotted and vacation used so far
                        				'------------------------------------------------------------------
                        				IF VacationUsed < VacationAlotted then 
                        					showTimeOff = "JSshowUserTimeOffVacation('" + VacationAlotted + "," + VacationUsed + "');"
                        				else 
                        					showTimeOff = "alert('You have exhausted your time-off, please edit record.');"
                        				end if
                        			else if e.dataSubmitted.FK_PTO_TYPE_ID = 2 then
                        And this is my Javascript function:
                        Code:
                        function JSshowUserTimeOffVacation(VacationAlotted, VacationUsed){
                        
                        	var _msg = '<p align="center"><font size="4">Vacation Days Alotted: '+VacationAlotted+'.<br>Vacation Days Used: '+VacationUsed+'.<br><br>Do you want to continue?<br></font></p>';
                        	A5.msgBox.show('TIME-OFF',_msg,'ync',function(button){
                        	    if(button == 'yes'){
                        		    {dialog.Object}.submit();
                        	    }else{
                        	        //alert('Action Cancelled by user.')
                        	    }
                        	});
                        
                        }
                        My Problem is that the second parameter that i am trying to pass "VacationUsed" is coming up as undefined when the pop-up window shows and i dont understand why?
                        Also, the first value, "VacationAlotted" is showing up as "20,4" when it should only be "4". Where did I go wrong?

                        When I use the debugger "Debug(1)" all the values show up properly, but when the javascript that is suppose to show the user the info comes up it is incorrect?
                        Capture.PNG

                        Comment


                        • #13
                          Re: Display A Dialog box Xbasic during ajax call back

                          That's because you're not passing 2 params... just one. Look at your code... and manually replace your vars and interpret it...

                          showTimeOff = "JSshowUserTimeOffVacation('" + VacationAlotted + "," + VacationUsed + "');"

                          "JSshowUserTimeOffVacation('" + VacationAlotted + "," + VacationUsed + "');"

                          "JSshowUserTimeOffVacation('" + 29 + "," + 12 + "');"

                          JSshowUserTimeOffVacation(' + 29 + , + 12 + ');

                          JSshowUserTimeOffVacation('29,12');

                          You're sending back 1 param.

                          You're missing single quotes around the comma separating the params. You're statement should be...

                          showTimeOff = "JSshowUserTimeOffVacation('" + VacationAlotted + "','" + VacationUsed + "');"

                          JSshowUserTimeOffVacation('29','12');

                          Comment


                          • #14
                            Re: Display A Dialog box Xbasic during ajax call back

                            That did the trick, I was following your example in post #10. In that post, it is missing the single quotes.

                            Thank you as always!

                            Comment


                            • #15
                              Re: Display A Dialog box Xbasic during ajax call back

                              Oooops... easy to spot stuff you're not writing. The missing single quotes were really standing out in your post... never saw them in mine. I usually run the code I post... gotta be sure to do that in future. Cheers.

                              Comment

                              Working...
                              X