Icalendar ICS Rails : How to event directly to my calendar without subscription - ruby-on-rails-4

I'm using the icalendar gem.
I have gone through icalendar methods but I could not find any useful information. Here's the code I have so far:
#calendar = Icalendar::Calendar.new
event = Icalendar::Event.new
event.uid = 'UID333'
event.dtstart = Icalendar::Values::Date.new('20190828')
event.dtend = Icalendar::Values::Date.new('20190829')
event.summary ="THIS IS SUMMARY"
event.description = "THIS IS DESCRIPTUON"
event.location = "THIS IS LOCATION"
#calendar.add_event(event)
#calendar.publish
render plain: #calendar.to_ical
I want to add event to my Outlook calendar without a subscription. With above code it is adding event with a subscription under "other calendar" as 'untitled'. My goal is to directly add it to my Outlook default calendar. Is this possible, and if so, does anyone have an example of how it can be done?

Related

Rally Web Services API: How do I get the URL link of the user story? (getDetailUrl() method)

Please be patient and Do Not flag this as duplicate: Using the Rally REST API, how can I get the non-API (website) URL for a user story?
I want to be able to generate a link for the user story.
Something like this: https://rally1.rallydev.com/#/-/detail/userstory/*********
As opposed to this: https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/88502329352
The link will be integrated into another application for the managers to see the user story.
I did read about the getDetailUrl() method, but in my case I am creating the user stories by parsing email and linking that to a notification service in Slack.
I am aware of the formattedID and (_ref), but I would have to query for it again, and I am creating batches of userstories through a loop. I need the actual web site link to the user story.
Here is my sample code:
public void CreateUserStory(string workspace, string project, string userstoryName){
//authenticate with Rally
this.EnsureRallyIsAuthenticated();
//DynamicJsonObject for HierarchicalRequirement
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate[RallyConstant.WorkSpace] = workspace;
toCreate[RallyConstant.Project] = project;
toCreate[RallyConstant.Name] = userstoryName;
try
{
//Create the User Story Here
CreateResult createUserStory = _api.Create(RallyConstant.HierarchicalRequirement, toCreate);
Console.WriteLine("Created Userstory: " + "URL LINK GOES HERE");
}
catch (WebException e)
{
Console.WriteLine(e.Message);
}
}
We don't have a method in the .NET toolkit for doing this, but it's easy to create.
The format is this:
https://rally1.rallydev.com/#/detail/<type>/<objectid>
Just fill in the type (hierarchicalrequirement turns into userstory, but all the others are the same as the wsapi type) and the objectid from the object you just created.
var parameters = new NameValueCollection();
parameters["fetch"] = "FormattedID";
var toCreate = new DynamicJsonObject();
var createResult = restApi.create("hierarchicalrequirement", toCreate, parameters);
var type = Ref.getTypeFromRef(createResult.Reference);
var objectID = Ref.getOidFromRef(createResult.Reference);
var formattedID = createResult.Object["FormattedID"];
And you can specify fetch fields to be returned on the created object so you don't have to re-query for it.

IBM Watson Alchemy news iOS SDK Swift

The IBM Watson iOS SDK using the Alchemy News service on Bluemix returns a string result which requires parsing to pull out the fields like url and cleaned title. ref: https://github.com/watson-developer-cloud/swift-sdk
I pull the string into an array and parse it in swift3 using some string methods but this is pretty ordinary and can produce unpredictable results
Is there a more elegant approach where I can access specific fields, like the url and cleaned title which I am passing to a UITableViewCell to select and segue to the url link.
sample code:
let alchemyDataNews = AlchemyDataNews(apiKey: apiKey)
let failure = { (error: Error) in print(error) }
let start = "now-14d" // 7 day ago
let end = "now" // today
let query = ["count": "15",
"dedup": "true",
"q.enriched.url.title": "[IBM]",
"return": "enriched.url.url,enriched.url.title" "enriched.url.title,enriched.url.entities.entity.text,enriched.url.entities.entity.type"]
Also I have noticed the search string [IBM] has a prefix of 0, i.e. 0[IBM] and have also seen an "A". What do these prefixes mean and where are they documented
Here is one way you can access the fields from a returned payload.
alchemyDataNews.getNews(from: "now-4d", to: "now", query: queryDict, failure: failWithError) { news in
for doc in (news.result?.docs)! {
var cleanedTitle = doc.source?.enriched?.url?.cleanedTitle
var author = doc.source?.enriched?.url?.author
var title = doc.source?.enriched?.url?.title
}}
Also, here is a nice API reference link for alchemy data which contains all of the request parameters and filters.
https://www.ibm.com/watson/developercloud/alchemydata-news/api/v1/

EXM subscribe to list C#

I'm working on converting my old Sitecore (< 8) code to work with Sitecore EXM. I'm having a hard time adding users to Recipient Lists from code. The answers in this post: Sitecore 8 EXM add a contact to list from listmanager don't answer my questions completely, and since I cannot comment, I've decided to start a new topic.
My first problem is that my EcmFactory.GetDefaultFactory().Bl.RecipientCollectionRepository.GetEditableRecipientCollection(recipientListId) gives a compilation error on the RecipientCollectionRepository, it says it does not exist. So I've used slightly different code. My code now, is as follows:
var contactRepository = new ContactRepository();
var contactName = this.Email.Text;
var contact = contactRepository.LoadContactReadOnly(contactName);
contact = contactRepository.CreateContact(Sitecore.Data.ID.NewID);
contact.Identifiers.AuthenticationLevel = Sitecore.Analytics.Model.AuthenticationLevel.None;
contact.System.Classification = 0;
contact.ContactSaveMode = ContactSaveMode.AlwaysSave;
contact.Identifiers.Identifier = contactName;
contact.System.OverrideClassification = 0;
contact.System.Value = 0;
contact.System.VisitCount = 0;
var contactPreferences = contact.GetFacet<IContactPreferences>("Preferences");
contactPreferences.Language = "nl-NL";
var contactEmailAddresses = contact.GetFacet<IContactEmailAddresses>("Emails");
contactEmailAddresses.Entries.Create("test").SmtpAddress = this.Email.Text;
contactEmailAddresses.Preferred = "test";
var contactPersonalInfo = contact.GetFacet<IContactPersonalInfo>("Personal");
contactPersonalInfo.FirstName = contactName;
contactPersonalInfo.Surname = "recipient";
if (recipientList != null)
{
var xdbContact = new XdbContactId(contact.ContactId);
if (!recipientList.Contains(xdbContact, true).Value)
{
recipientList.AddRecipient(xdbContact);
}
contactRepository.SaveContact(contact, new ContactSaveOptions(true, null));
}
So the recipientList is found, and the first time I add a contact to it, it increases the "Recipients" to 1 (checked using the /sitecore/system/List Manager/All Lists/E-mail Campaign Manager/Custom/RecipientList).
I also have a message which has this Opt-in recipient list, but when I check that message, it says it will be sent to 0 subscribers.
Any thoughts on this?
See this article listing known issues in Sitecore EXM:
https://kb.sitecore.net/articles/149565
"The recipient list shows "0" total recipients after recipients have been subscribed to the list. (62217)"
I got around this in a sandbox environment by adding a simple list (from csv, one contact) to the message. This upped the total recipient count from 0 to 1 which allows the message to be activated. All recipients in the composite list were sent a message.
Do you have a distributed environment? If so the RecipientCollectionRepository will not work as it is only available on a Content Management server. You could try using the ClientApi:
ClientApi.UpdateSubscriptions(RecipientId recipientId, string[] listsToSubscribe, string[] listsToUnsubscribe, string managerRootId, bool confirmSubscription)
and just add the id of the list you want to subscribe people to in the first string array.
Just a quick note with this option, listToUnsubscribe does not actually remove a contact from a list. You are meant to pass through the ID of the opt out list. This basically excludes them from any future emails. One draw back is that you will no longer be able to resubscribe them.
If this does not work for you you will need to create your own API between your CD server and your CM server where the CM server uses the recipientCollectionRepository to subscribe and unsubscribe

Call Slack API via VBScript Rule in Outlook

I'm trying to run a rule in Outlook that runs a VBScript which calls a Slack.com webservice and updates one of my Slack Channels with a specific message. Current state -- i just want it to post a static message. Future state i'm going to try to use RegEx to parse out certain data from the email and post it to my slack channel.
From frankensteining a few scripts i found online, this is what i have (but doesn't quite work) Hoping someone can help...
Function ProcessSend()
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
strEnvelope = "payload={""channel"": ""#edt-error"", ""text"": ""This is posted to #edt-error.""}"
Call oXMLHTTP.Open("POST", "https://custom-slack-url-for-service-goes-here.com" & posFirm, False)
Call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call oXMLHTTP.Send(strEnvelope)
Dim szResponse: szResponse = oXMLHTTP.responseText
Call oXMLDoc.LoadXML(szResponse)
If (oXMLDoc.parseError.ErrorCode <> 0) Then
'call msgbox("ERROR")
response = oXMLHTTP.responseText&" "&oXMLDoc.parseError.reason
'call msgbox(oXMLDoc.parseError.reason)
Else
response = oXMLDoc.getElementsByTagName("string")(0).ChildNodes(0).Text
End If
End Sub
So I resolved this myself, but wanted to post more details.
Request : I want to make a call to Slack and update one of my channels with a custom message WHEN I receive an email and an Outlook rule is triggered (message from X and sent to Y).
Solution : First off, you need to navigate to selfcert.exe in your Microsoft Office folders on the C drive, create a new self-signed certificate, and then add that certificate to Trusted Publishers in Outlook. AFTER that's done, I opened Visual Basic from Outlook by pressing Alt+F11 and created the following script in the "ThisOutlookSession" project.
Sub ProcessSend(Item As Outlook.MailItem)
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
strEnvelope = "payload={""channel"": ""#edt-error"", ""text"": ""This is posted to #edt-error.""}"
Call oXMLHTTP.Open("POST", "https://INSERT-YOUR-SERVICE-URL-HERE" & posFirm, False)
Call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call oXMLHTTP.Send(strEnvelope)
Dim szResponse: szResponse = oXMLHTTP.responseText
Call oXMLDoc.LoadXML(szResponse)
End Sub
Finally I created a rule that looked for the appropriate parameters and then peformed a "Run this script" action. When you click on the "script" name in the rule, a window will popup and you can select the above script you already created.
Hope this is helpful to someone!

DocuSign / Salesforce integration - tags not appearing with template

I have a custom button in SalesForce to use the "One Click Option" Send Now feature. The button also specifies to use a template with tags already in it.
If I login to DocuSign and preview the document as the signer would see it, I can see the tags.
However, when I send a request from SalesForce using the Send Now feature, the tags are not visible when the signer views the documents. I know that the sender can tag the fields in SalesForce, but that seems to defeat the purpose of having a template with the tags already present.
Does anyone have a solution for this?
Here is the custom button code below:
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//*************************************************//
// One Click Option (default edit envelope screen)
OCO = 'Send'; //Ex: Tag
CRL = 'Email~{!New_Hire_Checklist__c.Correspondence_Email__c};FirstName~{!New_Hire_Checklist__c.First_Name__c};LastName~{!New_Hire_Checklist__c.Last_Name__c};Role~Applicant'
DST = '6005ADE1-54B2-4215-B060-C15E5821A695'
//********* Page Callout (Do not modify) *********//
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!New_Hire_Checklist__c.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//*******************************************//
I think I see the problem, lines 9 and 10 of your code are missing ending semi-colons ;. Try changing to this:
CRL = 'Email~{!New_Hire_Checklist__c.Correspondence_Email__c};FirstName~{!New_Hire_Checklist__c.First_Name__c};LastName~{!New_Hire_Checklist__c.Last_Name__c};Role~Applicant';
DST = '6005ADE1-54B2-4215-B060-C15E5821A695';
Notice the semi-colons added at the end of each line.