Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

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

Error Copying Layout Definition to Local Data Cache

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

    Error Copying Layout Definition to Local Data Cache

    I am in need of assistance. I've looked at this for far too long and I think a fresh set of eyes will help. I have a grid that has a button at the top to start emailing invoices to all the records in that grid. If first calls the function at the end of this code to go to the first record in the grid (just in case the user clicks to a different record in the grid). Then it calls the StartEmails function which incorporates the emailnew function. This worked fine at one point but I don't know why now I get an error as shown. It is supposed to create the pdf file of the invoice, then attach that to an email using a pre-defined gmail account that has been set up, and then move the next record and so forth and so on. It acts like it can't find the report but it does exist. Anyone who can help me, I would greatly appreciate it.

    Error.jpg

    Code:
    function StartEmails as c (e as p)
    dim deltempfile as c
    deltempfile = file.shortname_to_longname(file.temp_path_get())
    dim delrfile as c
    delrfile = deltempfile+"Invoice.pdf"
    a5_file_remove(delrfile)
    
    dim CurrRows as n
    CurrRows = e.__si.RecordCount
    
    dim x as n
    x = 1
    
    While x <= CurrRows
    	
    	dim jscmd as c = ""
    	jscmd = <<%js%
    	var rowNum = {grid.object}._selectedRow;
    	{grid.Object}.ajaxCallback('G',rowNum,'emailnew','','_getData=true',{});
    	{grid.Object}.setFocus(rowNum+1);
    	%js%
    	StartEmails = StartEmails + jscmd
    	x = x + 1
    		
    end while
    
    end function
    
    function emailnew as c (e as p)
    
    dim tempfile as c
    tempfile = file.shortname_to_longname(file.temp_path_get())
    dim rfile as c
    rfile = tempfile+"Invoice.pdf"
    dim invnum as n
    invnum = convert_type(e._currentRowDataNew.Invoice_Number,"N")
    
    dim args as sql::Arguments
    dim Options as p
    dim printOptions as p
    args.set("blank", "")
    args.set("arg_InvNum",invnum)
    options.propogateErrors = .t.
    printOptions.blank = ""
    reportname = "Email_Invoice@rims_web.alb"
    saveAS = "PDF"
    filter = "Invoice_Number = :arg_InvNum"
    order = ""
    filename = rfile
    a5w_report_saveAs(reportName,saveAs,filter,order,filename,global_variables(),printOptions,args,options)
    
    'send e-mail
    dim pe as p
    with pe
    	DIM useDefaultSettings as L = .F.
    	DIM smtp_server as C = a5w_getfromwebapprepository("smtp_server")
    	DIM smtp_username as C = a5w_getfromwebapprepository("username")
    	DIM smtp_password as C = a5w_getfromwebapprepository("password")
    	DIM smtp_port as C = a5w_getfromwebapprepository("port")
    	DIM smtp_SSLOption as C = "SSL"
    	DIM from as C = a5w_getfromwebapprepository("email_address")
    	DIM from_alias as C = a5w_getfromwebapprepository("alias")
    	DIM messageSubject as C = "McLaurin Parking Company   Account #: "+e._currentRowDataNew.Account_Number+"  Invoice #: "+e._currentRowDataNew.Invoice_Number
    	DIM sendTo as C = e._currentRowDataNew.Email_Address
    
    	DIM cc as C
    	DIM bcc as C
    	DIM loadMessageFromRepository as L
    	DIM messageNameInRepository as C
    	DIM messageBodyHTML as C= "<p><font color=#000080 face=Arial>Dear Customer,<br>Please find attached your latest parking invoice.&nbsp; You can pay this via check or online at <a href='http://www.mclaurinparking.com'>www.mclaurinparking.com</a>.<br>PLEASE NOTE:&nbsp; If you have already made a payment for this invoice and it has been received, the account balance on the invoice will reflect this.<br>The account balance will reflect any pre-payments, credits, and/or outstanding previous balances.<br>You can also register for online access to view your account information and get copies of invoices, receipts, and statements.&nbsp; To register, click on 'Login' from our website and then click the registration link.&nbsp; Fill out the registration form.&nbsp; If no errors are given when you click submit, the registration form will close and you can immediately login.<br>Thank you for your business!<br>McLaurin Parking Co.</font></p>"
    	DIM messageBodyText as C
    	DIM attachments as C
    	attachments = rfile
    	DIM storeMessageInOutbox as L = .T.
    	DIM clientSideEvent as P
    	DIM clientSideEvent.afterMessageSent as C
    	DIM showConfirmationMessage as L = .F.
    	DIM confirmationMessageSuccess as C = "Message was sent."
    	DIM confirmationMessageFailure as C = "Message was not sent because of an error."
    	DIM useDotNetLibrary as L
    	DIM sendWhen as C = "Immediate"
    	DIM WorkQueueFormat as C = "XbasicScript"
    end with 
    'debug(1)
    'resolve any property values that must be read from the repository
    a5_resolveRepositoryProperties(pe)
    
    dim flagError as l = .f.
    dim errorText as c = ""
    dim pEmailSettings as p
    dim pstore as p
    if pe.useDefaultSettings = .t. then 
    	dim pwp as p
    	pwp = a5_getWebProjectProperties()
    	if eval_valid("pwp.email") = .f. then 
    		flagError = .t.
    		errorText = "Email settings not found"
    		pStore.wasSent= "No"
    		pStore.errorText=errorText
    
    	else
    		pEmailSettings = pwp.email
    	end if 
    else
    	pEmailSettings.smtp_server = pe.smtp_server
    	pEmailSettings.smtp_username = pe.smtp_username
    	pEmailSettings.smtp_password = pe.smtp_password
    	pEmailSettings.smtp_port = pe.smtp_port
    	pEmailSettings.smtp_SSLOption = pe.smtp_SSLOption
    end if 
    
    
    dim pMessageSettings as p
    dim isHTML as l = .f.
    if pe.loadMessageFromRepository then 
    	dim key as c
    	key = pe.messageNameInRepository
    	message = a5w_GetFromWebAppRepository(key)
    	'determine if the message is HTML by looking for a closing tag
    	if atc("</",message) then 
    		pMessageSettings.html_message = a5_resolve_placeHolders_in_text(message,e,.t.)
    		pMessageSettings.message = ""
    	else
    		pMessageSettings.html_message = ""
    		pMessageSettings.message = a5_resolve_placeHolders_in_text(message,e,.f.)
    	end if 
    else 'message is NOT being loaded from repository
    	pMessageSettings.html_message = a5_resolve_placeHolders_in_text(pe.messageBodyHTML,e,.t.)
    	pMessageSettings.message = a5_resolve_placeHolders_in_text(pe.messageBodyText,e,.f.)
    end if 
    	
    pMessageSettings.send_to = a5_resolve_placeHolders_in_text(pe.sendTo,e,.f.)
    
    pMessageSettings.subject  = *html_to_text(a5_resolve_placeHolders_in_text(pe.messageSubject,e,.t.))
    
    pMessageSettings.attachments = a5_resolve_placeHolders_in_text(pe.attachments,e,.f.)
    pMessageSettings.cc = a5_resolve_placeHolders_in_text(pe.cc,e,.f.)
    pMessageSettings.bcc = a5_resolve_placeHolders_in_text(pe.bcc,e,.f.)
    pMessageSettings.from = a5_resolve_placeHolders_in_text(pe.from,e,.f.)
    
    pMessageSettings.from_alias  = *html_to_text(a5_resolve_placeHolders_in_text(pe.from_alias,e,.t.))
    
    pMessageSettings.lRelated = .f.
    pMessageSettings.ReturnReceipt = .f.
    	
    'if action does not define the sender, then read from saved email settings
    if pe.useDefaultSettings then 
    	if pMessageSettings.from = "" then 
    		pMessageSettings.from = pEmailSettings.from 
    	end if 
    	if pMessageSettings.from_alias = "" then
    		pMessageSettings.from_alias = pEmailSettings.from_alias
    	end if
    end if 
    	
    	
    dim flagAutowrap as l = .t.
    dim pFlagSent as p
    dim flagUseDotNetLibrary as l 
    flagUseDotNetLibrary = pe.useDotNetLibrary
    
    
    if flagError = .f. then 
    	'there was no error in retrieving the email settings
    	'now, do the work - send the e-mail
    	
    	dim SSLOption as c 
    	SSLOption = pEmailSettings.smtp_SSLOption
    
    	If pe.sendWhen = "Immediate" then 
    		pFlagSent = email_send_noprofile(pEmailSettings,pMessageSettings,SSLOption,flagAutowrap,flagUseDotNetLibrary)
    		flagError = pFlagSent.error
    		errorText = pFlagSent.errorText
    		if flagError = .f. then 
    			pStore.wasSent= "Yes"
    			pStore.errorText=""
    		else
    			pStore.wasSent= "No"
    			pStore.errorText=errorText
    		end if 
    	else
    		'add to WorkQueue
    		dim workData as c 
    		if pe.WorkQueueFormat= "XbasicScript" then 
    			'store xbasic script
    			dim pMessageSettingsText as c 
    			pMessageSettingsText = alltrim(*variable_to_script(pMessageSettings))
    			pMessageSettingsText = *for_each(x,chr(9) + x, pMessageSettingsText)
    			
    			dim pEmailSettingsText as c 
    			pEmailSettingsText = alltrim(*variable_to_script(pEmailSettings))
    			pEmailSettingsText = *for_each(x,chr(9) + x, pEmailSettingsText)
    			
    			workData = "Dim pEmailSettings as P" +crlf()+\
    			"with pEmailSettings" + crlf()+\
    			pEmailSettingsText+\
    			"end with" + crlf(2) +\
    			"dim pMessageSettings as P"+crlf()+\
    			"with pMessageSettings" + crlf()+\
    			pMessageSettingsText + \
    			"end with" + crlf(2)+\
    			"dim SSLOption as c" + crlf()+\
    			"ssLOption = " + s_quote(SSLOption)+crlf()+\
    			"dim flagAutoWrap as l" + crlf()+\
    			"flagAutoWrap = " + s_quote(flagAutowrap)+crlf()+\
    			"dim flagUseDotNetLibrary as l" + crlf()+\
    			"flagUseDotNetLibrary = " + s_quote(flagUseDotNetLibrary) + crlf(2)+\
    			"pFlagSent = email_send_noprofile(pEmailSettings,pMessageSettings,SSLOption,flagAutowrap,flagUseDotNetLibrary)"
    		else if pe.WorkQueueFormat = "XbasicProperties" .or. pe.WorkQueueFormat = "JSON" then 
    			'store xbasic properties
    			dim pWorkProperties as p
    			pWorkProperties.pEmailSettings = pEmailSettings
    			pWorkProperties.pMessageSettings = pMessageSettings
    			pWorkProperties.sslOption = SSLOption
    			pWorkProperties.flagAutoWrap = flagAutowrap
    			pWorkProperties.flagUseDotNetLibrary = flagUseDotNetLibrary
    			if pe.WorkQueueFormat = "XbasicProperties" then 
    				workData = property_to_string(pWorkProperties)
    			else if pe.WorkQueueFormat = "JSON" then 
    				workData = vartojson(pWorkProperties)
    			end if 
    		end if 
    		
    		
    		dim pWork as p
    		
    		pWork.id = api_uuidcreate()
    		pWork.workData = workData
    		dim flag as l 
    		dim pResult as p 
    		flag = a5w_SaveToWorkQueue(pWork,pResult)
    		pstore.wasSent = "Yes"
    		pstore.errorText = ""
    	end if 
    end if 
    
    
    'store message in outbox
    if pe.storeMessageInOutbox = .t. then 
    	
    	pStore.dateStamp = now()
    	pStore.subject = pMessageSettings.subject
    	pStore.sent_by = pMessageSettings.from
    	pStore.sent_by_alias = pMessageSettings.from_alias
    	pStore.sendto = pMessageSettings.send_to
    	pStore.cc = pMessageSettings.cc 
    	pStore.bcc = pMessageSettings.bcc
    	pStore.attachments = pMessageSettings.attachments
    	pStore.comments = ""
    	if pMessageSettings.html_message <> "" then 
    		pStore.message = pMessageSettings.html_message
    	else
    		pstore.message = pMessageSettings.message
    	end if 
    
    
    	
    		
    	dim flagMessageWasSavedInOutbox as l
    	dim pResult as p
    	'If an error occurs, pResult.errorText will contain the reason for the error.
    	flagMessageWasSavedInOutbox = a5_SaveToWebAppEmailOutBox(pStore,pResult)
    end if 
    
    'send Javascript back to browser to invoke client side method and display confirmation alert
    
    if pe.clientSideEvent.afterMessageSent <> "" then 
    	'Send back a javascript command to invoke the function
    	dim jsInvokeEvent as c 
    	jsInvokeEvent = <<%longstring%
    	var obj = {};
    	obj.messageWasSent = __msgSent__;
    	obj.errorRext = '__errorText__';
    if(window['__functionName__']) window['__functionName__'].call(this,obj);
    %longstring%
    	jsInvokeEvent = stritran(jsInvokeEvent,"__functionName__",pe.clientSideEvent.afterMessageSent)
    	
    	jsInvokeEvent = stritran(jsInvokeEvent,"__msgSent__",  iif( convert_type(pstore.wassent,"L") ,"true","false")  )
    	jsInvokeEvent = stritran(jsInvokeEvent,"__functionName__", js_escape(pStore.errorText) )
    
    	'add the Javascript command to e.Javascript - the variable that contains all of the Javascript to be sent back to the browser.
    	dim e.Javascript as c = default ""
    	e.Javascript = e.Javascript + ";" + crlf() + jsInvokeEvent
    end if 
    
    if pe.showConfirmationMessage = .t.
    	'Send back a javascript command to display the confirmation messge
    	dim jsAlert as c 
    	dim msg as c 
    	
    	
    	
    	
    	if convert_type(pstore.wasSent,"L") then 
    		msg = pe.confirmationMessageSuccess
    	else
    		msg = pe.confirmationMessageFailure
    	end if 
    
    	jsAlert = "alert('" + js_escape(msg) + "');"
    
    	'add the Javascript command to e.Javascript - the variable that contains all of the Javascript to be sent back to the browser.
    	dim e.Javascript as c = default ""
    	e.Javascript = e.Javascript + ";" + crlf() + jsAlert
    	
    	
    end if
    
    'Return a Javascript command
    'emailnew = "alert('You submitted a value of: " + js_escape(e._currentRowDataNew.lastname) + "');"
    'emailnew = e.Javascript
    a5_file_remove(rfile)
    
    end function  
    
    function GoToFirstRec as c (e as p)
    dim jscmd as c
    jscmd = <<%js%
    	{grid.Object}.setFocus(1);
    	%js%
    GoToFirstRec = jscmd
    
    end function
Working...
X