Dynamics CRM -'Mark Complete' button on Task is not working - dynamics-crm

My problem is almost similar to this thread.
We are using CRM 2016 online.
The "mark complete" button on Task activity is not working intermittently. It is unclear as to which scenario is causing the issue, however, we do have a validation (due date against current date) that fires on 'Save' of the form and prevents Save if validation fails. So if the user clicks 'Mark Complete', it is internally firing Save event which is causing the validation to occur. When I fix the validation error,save changes, and click 'Mark Complete' the button doesn't respond.
Having said that, I faced the same issue even though there was no validation (for example, no date field to validate). So I am unable to pin point the flow of events causing the issue.
Can anyone suggest how do I fix/debug this problem ?
Thanks
Rajesh

The function that fires on Save event if the validation fails add the following code after executionObj.getEventArgs().preventDefault():
if (typeof (Mscrm) != "undefined" && typeof (Mscrm.CommandBarActions) != "undefined") {
Mscrm.CommandBarActions.$P = false; //to enable Mark Complete to be clicked again
return false;
}

Related

How can I check element attribute after click before redirect?

I have a simple login form and I need to check whether button becomes disabled after clicking on it. The issue is that after click on submit, redirect happens, causing assertion step to fail due to element being detached from the DOM. My question is whether it is possible to somehow check visibility attribute of the element after click.
cy.get('[data-cy="email"]').type(this.user.email);
cy.get('[data-cy="password"]').type('valid');
cy.get('button[type="submit"]').click().should('be.disabled'); // this fails due to dettachment from the DOM.
I've attempted to use .then() after click, but that did not help. Using cy.intercept() is also not an option due to how app is written.
Thank you for any idea.
You can do this:
cy.get('button[type="submit"]').click()
cy.get('button[type="submit"]').should('be.visible').and('be.disabled')
When you get the message "element is detached from DOM", it means an action on the page (in this case submit event) has replaced the element with a new version.
If you want to check that the old version of the element has the disabled attribute, this kind-of works.
cy.get('button[type="submit"]')
.click()
.should($el => {
const disabledAttr = $el.attr('disabled')
expect(disabledAttr).to.eq('disabled')
})
But I think this would be flaky if there is a delay between .click() and the disabled attribute getting applied.
If you want to check that the new version of the element has the disabled attribute, this should work.
cy.get('button[type="submit"]').click();
cy.get('button[type="submit"]').should('be.disabled'); // runs after "page load" event

Kendo UI scheduler: make appointments that occur in the past 'read-only'

Is there a way to make appointments slots and grid cells that occur in the past read-only in the Kendo scheduler? It would be fantastic if the grid was editable, but only for slots that occur in the future.
I would like appointments that occurred in the past to not be movable, resizable or destroyable.
Ideally, I would still be able to double click on them to load my custom form as read-only so people can still view the details of the reservation. I would then use template logic to make those fields read-only.
Just a mock-up of how I would do it... you'll probably have to do that with all the previously mentioned events though.
---> outside your scheduler but still accessible to it
var today = new Date(milliseconds);
---> events in your scheduler - in this case the edit option...
edit: function (e) {
if (kendo.toString(e.event.end, "fff") < today ) {
e.preventDefault();
}
else {
console.log("Hope that helps?")
}
}
Hope it helps!

How can I update Yii's CListView when a new record was added triggered by an AJAX call?

Yesterday I was introduced to the CListView and could manage to display all the information i want about my records, and in the format i want. I have a 'create' button (add a new contact), which opens a modal pop up window with the corresponding fields. When this window is closed, i return to the CListView, and here is my issue: i've been trying to update the CListView (without any luck, clearly).
I believe it should be easy to update the clistview with this call: $.fn.yiiListView.update('CListViews's ID'), but i can't find the proper event that should trigger this call.
Next, i post what i would think is the relevant code:
Button
echo CHtml::ajaxButton ("Create",
CController::createUrl('/contacts/create'),
array('onclick'=>'
$("#createContact").dialog("open");
return false;',
'update'=>'#createContact'),
array('id'=>'showCreateContactDialog'));?>
CListView
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>new CArrayDataProvider($model->contacts, array('pagination'=>array('pageSize'=>5,),)),
'itemView'=>'_view',
'emptyText'=>'empty',
'template'=>"{items}\n{pager}",
'pagerCssClass'=>'page-number',
'id'=>'ajaxListView',
));?>
Any help is more than welcome!! Hope this helps someone eventually as well.
If I understand correctly, your problem is finding what to trigger the CListView update with (the JS update snippet you provide should work fine).
Probably the jQuery dialog event close is what you are looking for; it will get triggered after the dialog has been closed. Alternatively, there is also a beforeClose event that has the additional capability to prevent the dialog from closing.

Google Chrome Extension - How can I include a content script more than once?

I've been working on Chrome Extension for a website for the past couple of days. It's coming along really nicely but I've encountered a problem that you might be able to help with.
Here's an outline of what the extension does (this functionality is complete):
A user can enter their username and password into the extensions popup - and verify their user account for the particular website
When a user browses http://twitter.com a content script is dynamically included that manipulates the DOM to include an extra button next to each tweet displayed.
When a user clicks this button they are presented with a dialog box
I've made a lot of progress but here is my problem:
When a user visits Twitter the content script is activated and all tweets on the page get my new button - but if the user then clicks 'More...' and dynamically loads the next 20 tweets... these new additions to the page DOM do not get affected by the content script (because it is already loaded).
I could add an event listener to the 'More...' button so it then triggers the original content script again (and adds the new button) but i would have to predict the length of twitter's ajax request response.
I can't tap into their Ajax request that pulls in more tweets and call my addCurateButton() function once the request is complete.
What do you think is the best solution? (if there is one)
What you want to do is to re-execute your content-script every time the DOM is changed. Luckily there is an event for that. Have a look at the mutation event called DOMNodeInserted.
Rewrite your content script so that it attaches an event listener to the body of the DOM for the DOMNodeInserted event. See the example below:
var isActive = false;
/* Your function that injects your buttons */
var inject = function() {
if (isActive) {
console.log('INFO: Injection already active');
return;
}
try {
isActive = true;
//inject your buttons here
//for the sake of the example I just put an alert here.
alert("Hello. The DOM just changed.");
} catch(e) {
console.error("ERROR: " + e.toString());
} finally {
isActive = false;
}
};
document.body.addEventListener("DOMNodeInserted", inject, false);
The last line will add the event listener. When a page loads the event is triggered quite often so you should define a boolean (e.g. var isActive), that you initialize to false. Whenever the inject function is run check whether isActive == true and then abort the injection to not execute it too often at the same time.
Interacting with Ajax is probably the hardest thing to coax a content script to do, but I think you’re on the right track. There are a couple different approaches I’ve taken to solving this problem. In your case, though, I think a combination of the two approaches (which I’ll explain last) would be best.
Attach event listeners to the DOM to detect relevant changes. This solution is what you’ve suggested and introduces the race condition.
Continuously inspect the DOM for changes from inside a loop (preferably one executed with setInterval). This solution would be effective, but relatively inefficient.
The best-of-both-worlds approach would be to initiate the inspection loop only after the more button is pressed. This solution would both avoid the timing issue and be efficient.
You can attach an event-handler on the button, or link that is used for fetching more results. Then attach a function to it such that whenever the button is clicked, your extension removes all the buttons from DOM and starts over inserting them, or check weather your button exists in that particular class of DOM element or not and attach a button if it doesn't.

ModalPopUpExtender with checkbox validation

I have an AJAX Application that I have been working on. At this point in the development - I have a modalpopupextender with a warning message and an OK and Cancel button. I have just been tasked with changing this to be three checkboxes and having the OK button disabled until all three boxes have been checked. I'm having a difficult time trying to accomplish this. I'm not sure if I should use a checkboxlist control or just three checkboxes. I am also not sure if the enabling/disabling of the button should be handled through javascript or codebehind. I have tried a little of both - with no success so any guidance is very much appreciated.
Three checkboxs would seem to work quite well if you ask me.. you can have each check box run the same validation function to check on the other 2. Also, i have found that using 'this.disable=true' would work quite well for what you are trying to accomplish. This way everything is handled under JS and there is no need to use the codebehind.
function validate() {
if ('checkbox is not checked')
return;
if ('checkbox2 is not checked')
return;
if ('checkbox3 is not checked')
return;
submit.disabled = false;
}

Resources