Set `scheduledend` on Appointment to null with Javascript - dynamics-crm-2011

I'm writing Javascript on an Appointment form and need to clear scheduledend DateTime field.
I've tried the obvious way, but it does not work.
Xrm.Page.getAttribute('scheduledstart').setValue(null);
Xrm.Page.getAttribute('scheduledend').setValue(null); // Both do nothing
How do I make the DateTime field blank?

This should work.
I've just tested on appointment form 'onLoad'
crmForm.all.scheduledend.DataValue = ''

You are right you can clear the value -
Xrm.Page.getAttribute('scheduledend').setValue();
Should work.

Related

Check if values in a form have been changed

Good Afternoon!
I have a situation and I don't know how solve it!
I'm using primefaces and I have a fieldSet with several fields and a commandButton called "Save" disabled inside it. So I need to enable the commandButton if any value of any field were modified. I know that there's the "onChange" event, but I have many fields, I would like to know if there's a way to check the whole form, I mean all fields at once, not field by field!
I'm using Primefaces 5.1
PS: If I wrote something wrong please sorry, just ask me and I will try to put it in other words!
Thank you all in advance

When hand-coding CodedUI Tests, is there a way to clear text inputs before populating them?

My goal is to clear text inputs before populating them.
For example, I am populating form fields using:
Keyboard.SendKeys(myInput, "Some Text");
My form populates fields on page load using cookie values.
When I try to use CodedUI to populate the email field, it appends a string to the current value instead of adding the desired value only.
My goal is to use CodedUI to populate the email field with:
foo#bar.com
But, since the field is already aaa#bbb.com (populated with cookie data on page load), it ends up being:
aaa#bbb.comfoo#bar.com
This worked. Set the text property before sending keys:
myInput.Text = "";
Keyboard.SendKeys(myInput, "Some Text");
You could try to double click the field to select all text, when the text is selected it will be overwritten.
Mouse.DoubleClick(myInput)
Maybe better is to clear the cookies before each test run
BrowserWindow.ClearCookies()
I've used the following with success:
control.SetFocus();
Keyboard.SendKeys("a", System.Windows.Input.ModifierKeys.Control);
Keyboard.SendKeys("{Delete}");
Keyboard.SendKeys(control, value);

using jscolor.js on dynamic input

i'm using color picker from http://jscolor.com/
i'm trying to attach it to some dynamic inputs, but to no avail. dynamic inputs in terms of, on page load the input doesn't exist, only after the user click on something the input will become available. for example, I have a rows of data, and each row has different background color. this row of data are loaded using ajax. at the end of each row, there's an edit button. by clicking the edit button, it will display an input text box for the clicked row. I want to call the jscolor picker when the user clicks on the input text box. how can I do this?
thanks
For some reason jscolor.init() did not work for me, and looking at the code I called
jscolor.installByClassName("jscolor");
function.
So...
$(document).ready(function() {
jscolor.installByClassName("jscolor");
});
Hope it helps
I just had this problem too but luckily it's easy to fix. You need to (re)init jscolor after you have dynamically created your inputs:
jscolor.init()
This helped me
<script>
$(document).on('click', '#myPickerId', function () {
var obj = $(this)[0];
if (!obj.hasPicker) {
var picker = new jscolor.color(obj, {}); //
obj.hasPicker = true;
picker.showPicker();
}
});
</script>
In my case, the picker control was dynamic because it is inside Knockout.js 'with' statement which hides and recreates the picker when it needs.
Got the same problem upon adding input fields dynamically
Managed to make it work by calling
jscolor.install();
PS: jscolor v2.4.5
As of 2020, the original problem should be solvable by dynamically creating an input element, and then calling new jscolor(input). Using JQuery (you could use vanilla JS as well):
var color_input = $('<input class="jscolor" spellcheck="false">');
new jscolor(color_input[0]);
This will make the popup picker appear on click, and everything appears to work just fine. However, you cannot manipulate it programmatically. To set the color using the objects above, you would normally use a method like: color_input[0].jscolor.fromString("#B7B7B7"). But that will fail for dynamically created objects, as color_input[0].jscolor is undefined. I believe this is a bug in Jscolor (and probably very easily solvable), as the missing object is actually available with color_input[0]._jscLinkedInstance. So you can just set the object yourself on instantiation with:
var color_input = $('<input class="jscolor" spellcheck="false">');
color_input[0].jscolor = new jscolor(color_input[0]);
And then everything looks to be working as expected. Hopefully this helps someone else that comes across this answer page as I did.

I would like to print selected documents from a view

Does anyone have a suggestion on how to print selected documents in an simple xPages view. I'm converting a legacy application. Which used the following Lotus script code to print. Thanks
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
count = collection.count
If count = 0 Then
Goto errSelectDocs
End If
Stop
For i = 1 To count
'
Set note = collection.GetnthDocument (i)
Set Source2 = w.EditDocument( False, note )
Set Source3 = w.ComposeDocument("","","mRecensement imp")
Call Source3.print(1)
Call Source3.close
Call Source2.close
'----------------------------------
nextdocument:
Next
I'm going to answer here rather the following up in the comments of the Simon answer.
so ok. We're saying build a new page with a repeat control of the select documents. and the question asker is saying, I THINK, that it seems wrong to do:
doc:NotesDocument=database.getDocumentByID(rowData);
return doc.getItemValue("xxxx") for 30 + items
right. You don't want to do that. should work. But icky to do.
Probably what I would do is create a SSJS function to pass rowData into. In that function build an array. Load the document once... put all the items into the array and pass them back to the page with the repeat control.
Probably what you do then is have a panel and use either a dataContext or objectData that's bound to the panel. Inside the panel is your page and fields. Those fields just read from the dataContext or objectData. so you're only getting the document once. I guess you could even use just a scoped variable though I don't think there's an event to call code on each row. So you'd need to hack it into the first field maybe or something.
But that's what you want. I previously asked a question on StackOver flow about returning multiple parameters like this: How to pass variable parameters to an XPages SSJS function?
Maybe that's helpful.
Someone might come up with a better solution but one option is this.
First have your viewPanel on your first XPage. Select your documents and click a button. The code would do this.
var viewPanel = getComponent("viewPanel1");
sessionScope.documentIDs = viewPanel.getSelectedIds();
You then hand it off to another XPage which has a repeat control of the print structure for a document. It reads the document ID's and creates the page. Then just use the normal print command after loading.
window.print();

before submit event in jqgrid

I hav got 2 jquery date picker fields in my form.One for start date and another for end date.
i want to check whether start date is less than end date . for that i used beforesubmit event5 of jqgrid but how to check it using javascript and am using php as server side lang...
please answer me as am beginner to jqgrid
You can also check it in PHP file which you define in your editurl in the Grid. If it goes wrong just return the error and check for the returning error in the AfterSubmit function in Add Options in your jqGrid.

Resources