With react hook form, I am using watch to detect when inputs change, and remove errors as soon as an input change is detected...
const [authError, setAuthError] = useState<string>("");
const watchFields = watch(["email", "password", "confirmPassword"]);
useEffect(() => {
setAuthError((error) => {
console.log("use effect error value = ", error);
return error ? "" : error;
});
console.log(watchFields);
}, [watchFields]);
The problem is this code is always setting the error and then immediately resetting to an empty string. Below is the log whereby I:
set the email input to one already registered
set password and confirm password, and then hit submit
The error is correctly being set to Email address in use
['somit#somit.co.uk', '11111111', '11111111']
['somit#somit.co.uk', '11111111', '11111111']
use effect error value =
use effect error value =
POST https://... 400
['somit#somit.co.uk', '11111111', '11111111']
use effect error value = Email address in use
use effect error value = Email address in use
['somit#somit.co.uk', '11111111', '11111111']
use effect error value =
use effect error value =
But then it is being overridden as for some reason the watchFields triggers again - even though the inputs haven't changed. Am I trying to use watch incorrectly?
Related
I tried obtaining the reply to the mail by using RDOMail.Reply method.
However, after inspecting the returned object, I've noticed that the signature is not part of the HTMLBody property, as it is when using method MailItem.Reply (which I'm not using because it throws 0x80004004 (E_ABORT) exception). Also, attachments that would be needed for the signature if it contains images are not preserved as they are with MailItem.Reply.
I've tried applying the signature separately, using Signature object. This adds signature to the HTMLBody, but doesn't use the _MailAutoSig attribute to mark the signature part therefore if I select "Change signature" from Outlook Ribbon, signature doesn't get replaced because Outlook has no way of knowing it is a signature.
Is there a way to obtain reply from RDOMail that would contain signature Outlook knows how to replace?
var rdoMail = session.GetMessageFromID(entryid);
var reply = rdoMail.Reply();
reply.HTMLBody = "";
var Account = session.Accounts.GetOrder(rdoAccountCategory.acMail).Item(1);
var signature = Account.ReplySignature;
signature.ApplyTo(reply, false);
reply.Save();
This is a known issue/case when dealing with Extended MAPI code and it is not related to Redemption only. See Messages that are created outside Outlook do not include the default Outlook email signature for more information.
Your choices are:
Mimic the Outlook behavior by adding all the necessary parts like _MailAutoSig attribute to the message body.
Use the Outlook object model with the Reply method and then getting the Redemption equivalent by using the GetRDOObjectFromOutlookObject method. But as far as I can tell, looking at the exception you get, it is not possible because the code is used from a secondary thread, right?
You can use its RDOAccount object (accessible in any language, including VBA). New message signature name is stored in the 0x0016001F property, reply signature is in 0x0017001F.
You can also use the RDOAccount.ReplySignature and NewSignature properties.
Redemption also exposes RDOSignature.ApplyTo method that takes a pointer to the RDOMail object and inserts the signature at the specified location correctly merging the images and the styles:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Drafts = Session.GetDefaultFolder(olFolderDrafts)
set Msg = Drafts.Items.Add
Msg.To = "user#domain.demo"
Msg.Subject = "testing signatures"
Msg.HTMLBody = "<html><body>some <b>bold</b> message text</body></html>"
set Account = Session.Accounts.GetOrder(2).Item(1) 'first mail account
if Not (Account Is Nothing) Then
set Signature = Account.NewMessageSignature
if Not (Signature Is Nothing) Then
Signature.ApplyTo Msg, false 'apply at the bottom
End If
End If
Msg.Send
This is a similar question to this link, but slightly different:
Skipping blank emails in Google Apps Script Mail Merge
I have a form/sheet set up that, when the users fills out the form, it generates a receipt email (does not contain the form contents as some receipts do) that is then sent to the recipient. However when the user leaves this field blank I get a form trigger error, which is understandable why the script didn't finish. I am trying to figure out how to keep the script from attempting to send an email when the recipient/email field is blank. Unfortunately, making the email field required on the form is not an option since, oddly, not everyone would have an email address (if this were an option I would certainly just require an email address to be entered).
I have tried the following code snippet based on the link provided above.
// Send Email to recipient(s) declared above in #var sendEmail
if (e.values[11] != null) {
var sendEmail = e.values[11]; //email field column
var subject = "subject message";
var body = "body message";
MailApp.sendEmail(sendEmail, subject, body, {
name: "Community Home Health Care",
body: body,
noReply: true,
})
I have also tried instead of
(e.values[11] != null)
using
(e.values[11] != "")
The remaining code I have omitted (goes above what I have shown) simply takes the form field responses and generates a document converted to a PDF which works as expected. The email section also works, just trying to eliminate the failed script emails I get occasionally.
Thanks
First is an assumption that 12 items are passed (0 through 11) and the email is the last item to be passed. If that is the case, then test that the item is defined with:
if(typeof e.values[11] !== 'undefined')
If you are using the Mail Merge Tutorial linked to in the post you linked to, and using the getRowsData() function to get your form responses, you should be able to use the Header of the column containing the email address such as e.values.emailAddress and get:
if(typeof e.values.emailAddress !== 'undefined')
This may vary based on how your data is defined.
Occasionally sending mails fail with the Mail::send function of PrestaShop. I use a external mailserver, and the responsible person there told me that no request was received for sending any mails (I find this strange though). So, I made a little logger doing the following:
if ( !Mail::send() )
// logging details here here..
The Mail::send returns false correctly. Now I would like to know the reason. Therefore I would like to log information about the connection in SwiftMailer. Could someone give me any clues how to solve this in a simple manor (not with SwiftMailer plugins, if possible).
Swift Mailer version: 3.3.2
If you set $die param to true you will cause that script stop and a bad experience for customer while buying or admin while changing order status, etc. You should check the following:
Check if email sending fails on specific email template. If true, you could have a problem with template structure, parameters passed, html rendering, etc.
Every error inside Mail::Send funtion is logged in Prestashop Logs. So you should check it there. You could know every possible error identifyng this kind of code inside function Mail::Send: Tools::dieOrLog(Tools::displayError('Error: invalid SMTP server or SMTP port'), $die);
Specific Swift exceptions are logged with this code: PrestaShopLogger::addLog('Swift Error: ' . $e->getMessage(), 3, null, 'Swift_Message'); so it should appear in Prestashop Logs too.
Anyway, Swift has his own log in class Swift_Log_DefaultLog. You can find it at \tools\swift\Swift\Log\DefaultLog.php. You could modify add or dump function to save logs to an specific file or similar.
Good luck.
Set $die parameter true to display the error. You will need _PS_MODE_DEV_ set to true to see it.
/**
* Send Email
*
* #param int $id_lang Language ID of the email (to translate the template)
* #param string $template Template: the name of template not be a var but a string !
* #param string $subject Subject of the email
* #param string $template_vars Template variables for the email
* #param string $to To email
* #param string $to_name To name
* #param string $from From email
* #param string $from_name To email
* #param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files
* #param bool $mode_smtp SMTP mode (deprecated)
* #param string $template_path Template path
* #param bool $die Die after error
* #param string $bcc Bcc recipient
* #return bool|int Whether sending was successful. If not at all, false, otherwise amount of recipients succeeded.
*/
public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
Alternatively you could go to backoffice and menu Advanced Parameters -> Logs, type in a Message filter: error and search for results. It's not guaranteed it will show you only email errors but it narrows it down a lot.
It is not possible to tell you the reason for failure of Mail::send() function. There can be multiple reasons for the failure.
There are 12 lines of code in that returns false in the Mail::send() function, each having a different condition. You need to debug the function to find the exact reason.
You can find the Mail::send() function in Mail.php file at /classes/Mail.php
Tip: You can add log with every 'return false;' statement in the function to check which of them is getting executed.
I tried to serialize a simple object inside the PCL it just returns a "{}" string. However, it does not throw any exceptions.
var test = new
{
Email = email,
Password = password,
Username = username
};
var testJson = JsonConvert.SerializeObject(test);
When I inspect the JsonConvertobject inside the VS debugger it says that the method SerializeObject is an unknown member. Furthermore, when I inspect the DeserializeMethod, it says:
Could not resolve type: global::Newtonsoft.Json.JsonConvert.DeserializeObject<DefaultResponse>
Both methods are displayed as variables inside the debugger.
I'm trying to use Facebook iOS SDK 3.5 for publishing an Open Graph action. My action is:
take a photo, and photo has an additional required string property named filter.
I am creating my graph object (all values are valid and working):
NSMutableDictionary<FBOpenGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:#"tonerapp:photo"
title:#"photo"
image:imageData
url:nil
description:title];
Then I add my filter:
object[#"tonerapp:filter"] = filterName;
I try to post the object, and I can confirm that my filter property is there (enabled FBSetting logging behavior for URL requests to show request data):
Body (w/o attachments):
object: {"description":"","type":"tonerapp:photo",
"tonerapp:filter":"classic","data":{},
"fbsdk:create_object":true,
"image":{"url":"fbstaging:\/\/graph.facebook.com\/staging_resources\/MDExMDE1MjkzNzU1Njc3MDE0MjoxNTM4NzgwNjUy","user_generated":"true"},
"title":"photo"}
I can see my filter property there, but the response is this:
error = {
code = 100;
message = "(#100) Object Missing a Required Value:
Object at URL '' of type 'tonerapp:photo' is invalid because
a required property 'tonerapp:filter' of type 'string' was not provided.";
type = OAuthException;
};
Well, it IS there. I tried all possible combinations such as:
object[#"data"] = #{#"tonerapp:filter": filterName}; //wrapping into the data object
object[#"data"] = #{#"filter": filterName}; //wrapping into data and removing namespace
object[#"toner:filter"] = filterName; //app name instead of namespace name
object[#"filter"] = filterName; //no namespace name at all
[object setObject:filterName forKey:#"tonerapp:filter"]; //setobject notation
[object setValue:filterName forKey:#"tonerapp:filter"]; //setvalue notation
[object setObject:filterName forKey:#"filter"]; //setobject AND without namespace...
and possibly more. I've tried everything, but the API always fails with the same error. I can verify the rest of the object is correct, if I go to my app in Facebook and set filter as optional instead of required, it posts successfully. Is it a bug/insufficient documentation with the Graph API, or am I so blind that I can't see something obvious here?
Thanks,
Can.
just put them under "data"
object[#"data"][#"youcustomproperty"] = #"smth";
Be sure your filterName is URL encoded. I had the same kind of issue with the name of a movie which was also a custom action on the graph. Try just to post a manual value only a simple string and let us know.