delete phone number using ews - powershell

I want to manage mailbox contacts in Exchange online using EWS 2.2 in PowerShell. I am able to create, delete and modify (most of the properties)
But I can not set any PhoneNumber (BusinessPhone, MobilePhone, HomePhone) to an empty value. Tried $updateItem.PhoneNumbers[[Microsoft.Exchange.WebServices.Data.PhoneNumberKey]::BusinessPhone] = $null;
and a lot of variations. Always get: "An object within a change description must contain one and only one property to modify."
I saw this post and using the code from there does not create any error message, but the phone number also isn't empty: EWS Delete PhoneNumber Entry on Contact
Any ideas how to set these field empty?

Related

Microsoft Graph Api {"code":"ErrorInvalidPropertySet","message":"Set action is invalid for property."}

We use
PATCH https://graph.microsoft.com/v1.0/users/{userId}/{messageId}/
to update the just created email draft in order to send it later.
During the call we get 400 error with the next text -> '{"error":{"code":"ErrorInvalidPropertySet","message":"Set action is invalid for property."}}'
We get it only for several mailboxes.
What could be the possible reason?
Is it related to the mailbox configuration? What should we pay attention to?
If you are trying to update a message use
PATCH /users/{id | userPrincipalName}/messages/{messageid}
this way. This error mainly occurs when you try to set a read only property. Please check if the payload which you are using is having any property with readonly access. Also go through this document.
The issue was in internetMessageHeaders field.
We used this field in our PATCH payload, but it is not presented in PATCH method at all and sometimes Microsoft Graph API returns 400, but sometimes not.(even in case of no error this field is ignored)
So if you face this issue - just check whether you send the internetMessageHeaders field in your payload or not.
I guess it could be applied to all other readonly fields.

Salesforce send Email by Apex

I'm making by a requirement a code able to send an E-mail to an specific list of E-mails, due the fact that I must to include the attachments of the record I decided to use an apex class instead an e-mail alert. This object (A custom object ) must populate some fields in an email template with some of the record´s fields. I implemented the following code
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(lista);
mail.setTemplateId('00X21000000QR22');
//mail.setWhatId(idMinuta);
mail.setTargetObjectId('005d0000005NMIx');
mail.setSaveAsActivity(false);
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (ContentVersion document: documents)
{
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(document.Title);
efa.setBody(document.VersionData);
fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
I understood that to make the fields merge it´s necesary to use the WhatId method. In the related code, I have commented it because It generates an error (INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.)
My question is, if is it possible to do this with a custom object. I´m a little confuse with salesforce documentation beacuse it looks like the method supports a custom object, or maybe If I am forggeting something to include in the code.
If i keep the WhatID line commented, effectively the email is sent with the attachments and the Template but it is not populated.
I really need this kind of solution because the org have in this object at least 20 email templates, for me will be easier just to pass the Id of the template instead of makig a code with 20 different html codes for each situation
Thanks a lot
Please publish this question at Salesforce StackExcahnge https://salesforce.stackexchange.com/

Is there a way to fetch latest email from "Mail reader sampler" or "Beanshell Sampler"

I am able to fetch email from my email account using POP3 via "Mail Reader Sampler" listener. But its not retrieving latest email.
Is it possible to extract the latest email using Beanshell Sampler. If yes, can you please share the code if this is achievable.
As per below discussion - looks like it is not doable. But, wanted to check if this is achievable using any means?
Stackoverflow Discussion on how to fetch required email
You can do this programmatically, check out the following methods:
Folder.getMessageCount() - Get total number of messages in this Folder
Folder.getMessage(int msgnum) - Get the Message object corresponding to the given message number
According to the JavaDoc
Messages are numbered starting at 1 through the total number of message in the folder.
So the number of the last message will always be the same as the total number of messages in the given folder.
Example code which reads last email using POP3 protocol
import javax.mail.Folder
import javax.mail.Message
import javax.mail.Session
import javax.mail.Store
String host = "host"
String user = "username"
String password = "password"
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties)
Store store = session.getStore("pop3")
store.connect(host, user, password)
Folder inbox = store.getFolder("Inbox")
inbox.open(Folder.READ_ONLY)
int msgCount = inbox.getMessageCount()
Message last = inbox.getMessage(msgCount)
//do what you need with the "last" message
inbox.close(true)
store.close()
I would also recommend forgetting about Beanshell, whenever you need to perform scripting - use JSR223 Elements and Groovy language as Groovy has much better performance, it is more Java-compliant and it has some nice language features. See Apache Groovy - Why and How You Should Use It guide for more details.

Workday: Put_Customer returning an error

We are using Snaplogic to load records into workday. Currently, extracting customer records from the source and trying to load them into workday using the object Put_Customer of web service Revenue_Management.
I was getting the following error:
But I'm not getting any category information from the source. So, I tried putting the value for Customer_Category_Reference as 1. But I ended up getting the following error.
The documentation for workday is not helpful and this has been a blocker for me for some time now.
Any help will be appreciated.
Update:
Trying to get customer categories using the Get_Customer_Categories object of Revenue_Management web service using Snaplogic. But getting the following error:
Failure: Soap fault, Reason: Processing error occurred. The task submitted is not authorized., Resolution: Address SOAP fault message and retry
Unfortunately I don't have access to a tenant at this time to validate . However it is likely to work based in prior experience . Perhaps you could create a customer in Workday, through the GUI. Then do get customer API call. Note the category reference . Then, use that in your put customer call
If you look at the API documentation, you will find that Put_Customer accepts a WID in the Customer_WWS_Data object. If you search for "Customer Categories" in Workday, you will likely find the report of the same name. Just select the category that you want your newly loaded customers to default to (click on the magnifying class, then on the ellipsis, Integration Ids, View Ids). The Workday ID will appear at the top.
I have not used the Revenue Management API, but my code for creating a position reference in the Compensation API is probably very similar to what you need to do for the Customer Category reference:
public static Position_ElementObjectType getPositionReference(string WID) {
return new Position_ElementObjectType {
ID = new Position_ElementObjectIDType[] {
new Position_ElementObjectIDType {
type = "WID",
Value = WID
}
}
};
}

Get message id (not universal id) from Notes document

I want to fetch message id of the document. I tried
document.getItemValueString("$MessageID");
but it's giving null.
Check out this thread from the Notes forum. You may need to follow the advice there, which is to set the saveMessageOnSend property to true before sending and then obtain the $MessageID from the copy of the document that is saved back to the mail database.
http://www-10.lotus.com/ldd/nd6forum.nsf/78d8a01e181f9b73852569fa0078668a/f08a0ebfc65537b185257b4300097939?OpenDocument
Otherwise, you may need to add a tilde before the dollar sign:
document.getItemValueString("~$MessageID");