Unable to cancel task - dynamics-crm

Issue: Timeout while canceling Task on Unified Interface
Tool: Dynamics 365 CRM, Version 1612 (9.0.2.192) (DB 9.0.2.192) online
Problem: We have a field on appointment form, has the value true and False. While saving we check if the value is true then, opens a New task window and we set a lookup(we created this lookup) like below,
var entityFormOptions = {};
entityFormOptions["entityName"] = "task";
formParameters["cmd_associatedmeeting"] = formContext.data.entity.getId().replace('{', '').replace('}', '');
formParameters["subject"] = "Created From " + getEntityType(ExecutionContext) + ": " + formContext.getAttribute(formElements_meeting.subject).getValue();
// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (success) {
if (window.console && console.error) console.log(success);
},
function (error) {
if (window.console && console.error) console.log(error);
});
We save a task record and synchronous workflow will create a Connection Record(We are using Connection entity to associate this record with appointment). Connection record contains
Connect To: Appointment
Connection From: Task
We click Close Task as Cancelled and we get an issue on Mobile (It works well in the browser). We are using UCI based app to use CRM in Mobile.
Error:
Operation timed out.
Key = [subject,cmd_iscloned,statuscode,description,regardingobjectid,cmd_associatedevent,cmd_associatedmeeting,statecode,ownerid,modifiedby,param_actGuid,statecode];
ContextString = Key: a7edbe81-875d-e811-a959-000d3a1c5096;
ColumnSet: [subject,cmd_iscloned,statuscode,description,regardingobjectid,cmd_associatedevent,cmd_associatedmeeting,statecode,ownerid,modifiedby,param_actGuid,statecode]; RetrievalStrategy: remote
it is getting completed but not canceled.
EDIT: If I cancel the Appointment record, I will be able to cancel the task.
Require help!

We were using Form Parameters to set lookup on task, we removed the form parameter and did it another way. and it worked. Issue no longer exist!

Related

Google API is not returning the events created from UI

I am using googleapis in NodeJS to create & fetch the calendar events. I am using the following method to get the list of events.
const getEvents = async (dateTimeStart, dateTimeEnd,timeZone) => {
console.log("Date Start : " + dateTimeStart + " date end :" + dateTimeEnd + " time zone " + timeZone);
try {
let response = await calendar.events.list({
auth: auth,
calendarId: CALENDER_ID,
timeMin: (new Date(dateTimeStart)).toISOString(),
timeMax: (new Date(dateTimeEnd)).toISOString(),
timeZone: timeZone,
singleEvents: true,
maxResults: 9999,
orderBy: 'startTime
});
let items = response['data']['items'];
console.log(items);
return items;
} catch (error) {
console.log(`Error at getEvents --> ${error}`);
return 0;
}
};
The above method returns only events that are created programmatically via googleapis. If I create the events directly on the calendar from the browser this does not return those events.
Any idea how to fetch all events even if they are created from browser.
Based on what you were explaining about the behavior of the events being created by the service account instead of the actual users I think the problem is that the events created through API are being created under the Calendar ID of the service account, and the ones created by the users through API may have a different Calendar ID, therefore when you try to get the list of events, since you are probably using the Calendar ID from the service account you get only those events created using the API and not the ones created by the users through the web UI.
In this case it may be necessary to make sure that every event is being created under the exact same calendar ID through the web UI and the API so that all the events no matter if they were created through the API or web UI get listed as expected.
Let me know if this is useful, otherwise I can edit the response to add more clarification depending on your specific situation.

nativescript-phone prevents Nativescript-contacts from returning

I have an app where I want to select a person from contacts and then send a text to that person. It works as expected for the first user, but after that the app never receives control after the contact is selected. I've isolated the problem to the Nativescript-phone plugin. If you simply call phone.sms() to send a text, and then call contacts.getContact(), the problem occurs. I see this on both Android and iOS.
I've created a sample app that demos the problem at https://github.com/dlcole/contactTester. The sample app is Android only. I've spent a couple days on this and welcome any insights.
Edit 4/21/2020:
I've spent more time on this and can see what's happening. Both plugins have the same event handler and same request codes:
nativescript-phone:
var SEND_SMS = 1001;
activity.onActivityResult = function(requestCode, resultCode, data) {
nativescript-contacts:
var PICK_CONTACT = 1001;
appModule.android.on("activityResult", function(eventData) {
What happens is that after invoking phone.sms, calling contacts.getContact causes control to return to the phone plugin, and NOT the contacts plugin. I tried changing phone's request code to 1002 but had the same results.
So, the next step is to determine how to avoid the collision of the event handlers.
Instead of using activityResult event, nativescript-phone plugin overwrites the default activity result callback.
A workaround is to set the callback to it's original value after you are done with nativescript-phone.
exports.sendText = function (args) {
console.log("entering sendText");
const activity = appModule.android.foregroundActivity || appModule.android.startActivity;
const onActivityResult = activity.onActivityResult;
permissions.requestPermissions([android.Manifest.permission.CALL_PHONE],
"Permission needed to send text")
.then(() => {
console.log("permission granted");
phone.sms()
.then((result) => {
console.log(JSON.stringify(result, null, 4));
activity.onActivityResult = onActivityResult;
})
})
}

How to create Action and Call action in MS Dynamics CRM?

How to create Action step by step and Call action in MS Dynamics CRM?
How many ways to call action in MS Dynamics CRM?
What the benefits of action instead of Workflow/plugin?
Actions
Actions are a type of process in Microsoft Dynamics 365. You can invoke actions, including custom actions, directly from a workflow or dialog, without writing code! More information: Invoke custom actions from a workflow or dialog
Actions can also be invoked by running custom code that uses the Microsoft Dynamics 365 Web services.
You can call actions:
It can be called from both client & server side, enabling the Single Point of Approach (Implement once, consume anywhere), for ex:- From code that executes within a plug-in, custom workflow and any C# code.
From a command that is placed in the application and executes the operation using JavaScript code.
Can receive input parameters and return output parameters in a straight forward manner, similar to an Organization level Web Service
From an integration with another system that uses the Microsoft Dynamics 365 web services.
From a custom client application that uses the Microsoft Dynamics 365 web services.
Why use actions?
Actions open a range of possibilities for composing business logic. Before Actions, the primary way to implement business processes was limited to plug-ins or custom workflow activities. With Actions, you can perform operations, such as Create, Update, Delete, Assign, or Perform Action. Internally, an action creates a custom Dynamics 365 message. With Actions you can create a custom message (for example: submitquote , leadtoax etc. Once an action is defined and activated, a developer can use that message like any of the other messages provided by the Microsoft Dynamics 365 platform.
Suppose you have button on Quote form which sends information from CRM to another platform (for ex another platform is AX).
Create and activate a Custom Action (Settings > Process)
Now you can call this Action(ofs_submitquotetoax) from JavaScript on some event (OnLoad, OnSave,etc). In this example I am calling the action from SUBMIT QUOTE button on Quote form which sending quote information to other system (AX).
// Call this below method from Button click event or from any event on the form
// For Alert.showLoding method you can see another Alert.js library
// For Process.callAction method you can see another Process.js library
// You can download Alert.js & Process.js from this Path: https://drive.google.com/drive/folders/0B2CUbevE8v9YMkZlMEhUZ3NJc1U
function submitquote() {
var actionName = "ofs_submitquoteax";
var entityName = Xrm.Page.data.entity.getEntityName();
var entityId = Xrm.Page.data.entity.getId();
Alert.showLoading("Submitting...", 400, 150);
var inputParams = [
{
key: "EntityRef", type: Process.Type.EntityReference,
value: new Process.EntityReference(entityName, entityId)
}
];
// call process callection method
Process.callAction(actionName, inputParams, cloneSuccessCallback, errorCallback);
}
function cloneSuccessCallback() {
Alert.hide();
Alert.show("Action Success", "", null, "SUCCESS");
Alert.hide();
var entityName = Xrm.Page.data.entity.getEntityName();
var entityId = Xrm.Page.data.entity.getId();
Xrm.Utility.openEntityForm(entityName, entityId);
//Xrm.Page.data.refresh();
}
function errorCallback(error, trace) {
alert(error);
alert(alert(error));
}
e, for this event you can register & trigger a Plugin and receive the input-parameter (in our case we sending input-parameter key as EntityRef in which we are sending entityName and entityId.
Parameters: Action Unique Name, Input Parameters (array), Success Callback (function), Error Callback (function), CRM Base URL (not required on forms/views)
Each Input Parameter object should contain key, value, and type. Types are defined by the Process.Type enum. EntityReference values should be an object containing id and entityType.
The Success Callback function should accept one argument which is an array of output parameters, each containing key, and value.
You can write plugin in below way and access input parameter
protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
{ // Register the plugin in PreValidation stage as this plugin will trigger from Javascript (Action)
if (localContext == null)
{
throw new InvalidPluginExecutionException("localContext");
}
IPluginExecutionContext context = localContext.PluginExecutionContext;
if (context.Depth > 1) { return; }
IOrganizationService service = localContext.OrganizationService;
ITracingService trace = localContext.TracingService;
Entity quoteEntity = null;
EntityReference qEntity = null;
if (context.InputParameters.Contains("EntityRef") && context.InputParameters["EntityRef"] is EntityReference)
{
//if (context.PrimaryEntityName.ToLower() != "quote") { return; }
qEntity = context.InputParameters["EntityRef"] as EntityReference;
if (qEntity.LogicalName.ToLower().Equals("quote"))
{
try
{
quoteEntity = service.Retrieve("quote", qEntity.Id, new ColumnSet("ofs_parentaccountid", "quotenumber", "revisionnumber", "ofs_well"));
// Execute Your logic
}
catch (Exception ex)
{
trace.Trace(string.Format("Exception Quote_Create_AXIntegration Plugin: {0}", new[] { ex.ToString() }));
}
}
}
else { return; }
}
Register your plugin and then register the step in below way, you can notice your custom message name in below screen-shot "ofs_submitquoteax";
Ref:https://community.dynamics.com/crm/b/mylifemicrosoftdynamiccrm/archive/2017/04/17/microsoft-dynamics-crm-actions

e.source and e.range missing/unavailable

I have a basic installable trigger I am trying to use to send an email invite based on when a Sheet is edited (a specific checkbox is selected in my case) however when I try and access the range or source object from my event object I get [object Object] and undefined respectively. However I know the event object is working thanks to being able get the oldValue, value, triggerUid, and user.
function onEditCheck(e) {
var cells = e.range.getA1Notation();
var name = e.source.getActiveSheet().getName()
console.log('cells: ' + cells);
console.log('sheet name: ' + name);
console.log('id: ' + e.triggerUid);
console.log('edit: ' + e.value);
if(e.oldValue === 'false' && e.value === 'TRUE') {
sendEmail(e.user.getEmail(), e.range);
}
}
The only other reference to this issue I could find was this question here however I have had no luck with the permissions "solution" they found.
Any help or insight would be appreciated.
This is because necessary authorization wasn't granted to your script.
Add this somewhere in your code:
//SpreadsheetApp.getActive()
This will trigger the oAuth flow and request the permission to access Spreadsheets, which was missing.
Related:
IssueTracker
User response missing on Form submit
This worked for me:
function createTrigger(){
var tr=ScriptApp.newTrigger('onEditCheck').forSpreadsheet('My SSID').onEdit().create();
}
function onEditCheck(e) {
var cell = e.range.getA1Notation();
var name = e.range.getSheet().getName();
var data=Utilities.formatString('<br />Cell Edited: %s<br />Name of Sheet: %s<br />TriggerId: %s<br />Value: %s<br />Old Value: %s<br />',cell,name,e.triggerUid,e.value,e.oldValue);
var userInterface=HtmlService.createHtmlOutput(data);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'Testing')
}
By the way it's really handy to go to the trigger editor after creating the trigger and set notifications to immediate. That way you'll get notifications to failures pretty fast from Google Server.

email read from EWS (exchange web service) server cannot process this request error c#

I have a task where i need to check the emails delivered to my mailbox and read them ,based on subject i have to do some task. But for demo purpose I have put only the basic functionality of just updating the email read status
The basic connection and creating service object everything is fine:
///////////
NetworkCredential credentials = new NetworkCredential(securelyStoredEmail, securelyStoredPassword);
ExchangeService _service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
_service.Credentials = credentials;
_service.AutodiscoverUrl("User1#contoso.com");
/////////////////////////
Here Everything works fine. However I will invoke the below method for every 60s using observable event of reactive linq. THis is to go and poll the my emailbox and read 100 emails for every 60 seconds.
Everything works fine till sometime. Sometimes when the control reaches the line of code inside parallel.foreach loop, it shows error message like 'server cannot process this request now. Please try later' something like this. THis error comes exactly at the line
var email = EmailMessage.Bind(_service, findItemsResult.Id, emailProps);
so for every 60 seconds, i will get this error sometimes.sometimes it works fine.
Below is the method which is executed for every 60seconds. Its like i try to read the emails from "myaccount.com" for every 60s and i vil get the error 'server cannot process'.
internal void GetEmailsFrommymailbox()
{
try
{
var view = new ItemView(100);
var userMailbox = new Mailbox(userMailbox);
var folderId = new FolderId(WellKnownFolderName.Inbox, userMailbox);
SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And,
new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
var findResults = _service.FindItems(folderId, sf, view);
var emailProps = new PropertySet(ItemSchema.MimeContent, ItemSchema.Body,
ItemSchema.InternetMessageHeaders);
Parallel.ForEach(findResults, findItemsResult =>
{
///////////// this is the line where i get error////////
var email = EmailMessage.Bind(_service, findItemsResult.Id, emailProps);
//// above is the place where i get error
var emailMatching = email;
try
{
email.IsRead = true;
email.Update(ConflictResolutionMode.AutoResolve);
}
catch (Exception emailreadFromBccException)
{
Logger.Warn(emailreadFromBccException + " Unable to update email read status");
}
});
}
}
Your getting that error because you being throttled https://msdn.microsoft.com/en-us/library/office/jj945066%28v=exchg.150%29.aspx and your being throttled because you code isn't very efficient.
Instead of doing
Parallel.ForEach(findResults, findItemsResult =>
{
///////////// this is the line where i get error////////
var email = EmailMessage.Bind(_service, findItemsResult.Id, emailProps);
You should use LoadPropertiesFromItems http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx . Which will reduce the number of call you need to make to the server.
I would also suggest you use Streaming notification https://msdn.microsoft.com/en-us/library/office/hh312849%28v=exchg.140%29.aspx?f=255&MSPPError=-2147217396 which will mean you won't need to poll the server every 60 seconds and just take an action when a new item arrives.
Cheers
Glen

Resources