Linking activities to an account in CRM 4.0 - dynamics-crm

I am developing an application using the CRM 4.0 web service interface and need to programatically create a phone call record and link it to an account record. I can see how to create the records but I am not sure how to link the phone call to the account. Any help would be much appreciated.
Thanks
Nigel

You can't directly link an activity (like phone call) to an entity (like account). You must use the activityparty object to do it.
To do it follow these steps (I am assuming the account exists):
phonecall newPhoneCall = new phonecall ();
// Set the properties of the newPhoneCall.
newPhoneCall.subject = "Test newPhoneCall";
newPhoneCall.description = "New newPhoneCall";
// Create the party sending and receiving the newPhoneCall.
activityparty party = new activityparty();
// Set the properties of Activityparty.
party.partyid = new Lookup();
party.partyid.type = EntityName.account.ToString();
party.partyid.Value = existingAccount.accountId;
// The party sends and receives the newPhoneCall.
newPhoneCall.from = new activityparty[] { };
newPhoneCall.to = new activityparty[] { party };
Then create the phone call activity as normal.

Related

Is it possible to scope a Teams Messaging Extension?

I developed a messaging extension for Teams. I want it to only be available for the teams i specifically install the app to. Is that possible and how? I can't find any info on this, but my use-case does not seem to be far-fetched, so i would expect it to be possible.
use-case: Members of a team use an external system to register cases. I want them to be able to search and reference cases within the teams corresponding project site in the external system. I add a tab to the general channel that refers to the project site, and the messaging extension uses the contentUrl of that tab to query the right case list. I don't want the extension to be available outside the teams channels. By default it seems that the extension is available in every chat input option.
Message extensions do no have a scope defined and they are available once you install it in teams. Currently, it is no possible to restrict to show the message extension in one team
I ended up responding with a card that handles the error:
private MessagingExtensionResponse errorResponse(string title, string errorText)
{
MessagingExtensionResult composeExtensionResult = new MessagingExtensionResult
{
Type = "result",
AttachmentLayout = "list",
Attachments = new List<MessagingExtensionAttachment>(),
};
ThumbnailCard h = new ThumbnailCard()
{
Title = title,
Text = errorText,
};
composeExtensionResult.Attachments.Add(h.ToAttachment().ToMessagingExtensionAttachment());
var messagingExtensionResponse = new MessagingExtensionResponse();
messagingExtensionResponse.ComposeExtension = composeExtensionResult;
return messagingExtensionResponse;
}
Although it would be nice to be able to scope the extension, this way i can catch some more invalid usage. For example:
var currentTeam = new TeamDetails();
IList<ChannelInfo> currentTeamChannels = new List<ChannelInfo>();
try
{
currentTeam = await TeamsInfo.GetTeamDetailsAsync(turnContext, turnContext.Activity.TeamsGetTeamInfo().Id, cancellationToken);
currentTeamChannels = await TeamsInfo.GetTeamChannelsAsync(turnContext, turnContext.Activity.TeamsGetTeamInfo().Id, cancellationToken);
}
catch
{
return errorResponse("Permission error", "This app has no permissions to this team / channel. Please add the app to this team / channel.");
}
Got the suggestion from this question: Is it possible for a teams messaging extension to return a plaintext response instead of a card?

Is it possible to programmatic-ally access the list of contacts in outlook using Office Add In

I am building an Add In which is supposed to grab in addition to the list of contacts an account has, the contacts (to, from, cc and bcc) that are used in the current Item (Message).
As per the documentation, the following instruction gave me zero contacts, although I have contacts in the contacts book, and reading a message with a sender email.
var contacts = Office.context.mailbox.item.getEntities().contacts;
I need to grab the list of contacts I manage in my account:
This list is accessible with the open graph APIs, I wonder if it's also accessible locally with the Office object for Office Add-Ins
Office Js does not provide APIs to get the list of contacts in the account.
But you can get an auth token from Outlook using authentication APIs, then use this token to acquire Graph token to interact with Graph APIs and get the list of contacts
Office.context.auth.getAccessTokenAsync(function (result) {
if (result.status === "succeeded") {
// Use this token to call Web API
var ssoToken = result.value;
// Now send this token to your server and acquire a Graph token
// Server can talk to Graph APIs and get contacts to display
} else {
// Handle error
}
});
Create a Node.js Office Add-in that uses single sign-on
It looks you misunderstood the documentation.
A quote:
The following example accesses the contacts entities in the current item's body.
var contacts = Office.context.mailbox.item.getEntities().contacts;
You could get all contacts using the below link:
Microsoft.Office.Interop.Outlook.Items OutlookItems;
Microsoft.Office.Interop.Outlook.Application outlookObj = new Microsoft.Office.Interop.Outlook.Application();
MAPIFolder Folder_Contacts;
Folder_Contacts = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
OutlookItems = Folder_Contacts.Items;
MessageBox.Show("Wykryto kontaktów: " + OutlookItems.Count.ToString());
for (int i = 0; i < OutlookItems.Count; i++)
{
Microsoft.Office.Interop.Outlook.ContactItem contact = (Microsoft.Office.Interop.Outlook.ContactItem)OutlookItems[i+1];
sNazwa = contact.FullName;
sFirma = contact.CompanyName;
sAdress = contact.BusinessAddressStreet;
sMiejscowosc = contact.BusinessAddressPostalCode + " " + contact.BusinessAddressCity;
sEmail = contact.Email1Address;
dataGridView1.Rows.Add(sNazwa, sFirma, sAdress, sMiejscowosc, sEmail);
}
For more information, please refer to the below link:
Get Outlook contacts into C# form-based application

How to create record for Phonecall Activity in Dynamics CRM 365 for 'CallFrom' and 'CallTo'

`if (!string.IsNullOrEmpty(phonecall.From))
phonecallEntity.Attributes.Add("from", new EntityReference("systemuser", new
Guid(phonecall.From)));
if (!string.IsNullOrEmpty(phonecall.To))
phonecallEntity.Attributes.Add("to", new EntityReference("contact", new
Guid(phonecall.To)));
I'm trying to set the from and to field on a Phone Call activity in Dynamics 365. I'm using the following code but the to and from fields are empty when creating a Phone Call. What do I need to change?
The to and from fields on Activity entities (line Phone Call) expect an EntityCollection, not an EntityReference as you are trying to pass them.
Each entity within your EntityCollection should be an ActivityParty linked to an EntityReference:
// Create your collection.
var collection = new EntityCollection();
// Create your parties; one party per reference (to/from).
var party1 = new Entity("activityparty");
party["partyid"] = new EntityReference(logicalName, id);
// Add your parties to your collection.
collection.Entities.Add(party1);
// Set your to phone call's to field.
phoneCallEntity["to"] = collection;

Using Places Library in App maker

Is there a way to call PlacesServices' getDetails function from App Maker?
I have the Place ID from the Geocoder but I'd like to be able to get details about the place.
At this time there is no built-in Places service in Apps Script and you'll need to through these steps to make it work:
Go to Google Cloud Console
Create a brand new project or use the project associated with your App Maker deployment:
Using left navigation menu go to APIs & Services -> Dashboard
Click + Enable APIs and Services button
Search for Google Places API Web Service and enable it
Go to APIs & Services -> Credentials and create new API key if you don't have one
Back in App Maker! =) Create a server script:
var API_KEY = 'PUT_YOUR_API_KEY_HERE';
var PLACES_URL = 'https://maps.googleapis.com/maps/api/place/details/json?placeid=';
function getPlaceDetails_(placeId) {
var URL = PLACES_URL + placeId + '&key=' + API_KEY;
var response = UrlFetchApp.fetch(URL);
var json = response.getContentText();
var placeDetails = JSON.parse(json);
return placeDetails;
}
This snippet is cornerstone for further scripting. You can use it with Calculated Model or just call it using google.script.run from client (note that for the second case you'll need to make this function public by removing underscore in the end of function name).

Authorization needed for classroom.profile.emails

I'm working on a web app in Google Apps Script, and I'm having some trouble understanding how the authorization is handled. When accessing the web app as the user using the app, it prompts for authorization, and everything appears okay. However, I'm call userProfiles.get and looking for student email addresses, and it returns the profile without the email.
function classRosters() {
var teacher = Classroom.UserProfiles.get(Session.getActiveUser().getEmail());
var classList = Classroom.Courses.list({teacherId: teacher.id}).courses;
var classes = [];
for (i in classList) {
if (classList[i].courseState != 'ACTIVE') {
continue;
}
var class = classList[i];
var classId = classList[i].id;
var className = classList[i].name;
classes.push([className]);
var teacherId = Classroom.Courses.Teachers.get(classId, classList[i].ownerId).userId;
var teacherEmail = Classroom.UserProfiles.get(teacherId);
var title = Classroom.Courses.get(classId).name;
var students = Classroom.Courses.Students.list(classId).students;
var studentArray = [];
if (students) {
for (j in students) {
var currStudent = students[j];
var email = Classroom.UserProfiles.get(currStudent.userId).emailAddress;
var email = Classroom.Courses.Students.get(classId, currStudent.userId).profile.emailAddress;
studentArray.push(email);
Logger.log(email);
}
}
for (j in classes) {
if (className.indexOf(classes[j]) > -1) {
var classIndex = +j;
classes[classIndex].push(studentArray);
}
}
}
return classes;
}
I've played with the API explorer, and it shows that classroom.profile.email is required, but that's not included in the scopes. When I use the API explorer, I can authorize, and it works, and my web app will work as well until the authorization from the explorer expires.
Is there any method to prompt for authorization in the GAS library for the Classroom advanced service? I can't find anything much that's specific to GAS and not part of the overall API.
Thanks,
James
Unfortunately Apps Script doesn't allow you to request additional scopes for your advanced services. The email and photos scopes aren't required to execute the method, but are required to return email and photo data in the response. You can follow issue 3070 for progress on this problem.
Update 2015-08-17:
We just implemented a workaround, which is that the Classroom advanced service now always prompts for the following fixed set of scopes:
https://www.googleapis.com/auth/classroom.courses
https://www.googleapis.com/auth/classroom.rosters
https://www.googleapis.com/auth/classroom.profile.emails
https://www.googleapis.com/auth/classroom.profile.photos
This provides access to emails, but does mean that the scopes requested for a given script may be more than it actually needs. We hope this unblocks admins that are trying to use Apps Script to manage their Classroom data, while we work on a longer-term solution for dealing with optional scopes in Apps Script.

Resources