Meteor is playing hard on me. I would like to have a Form where one field is a random number and cannot be changed. And Always changing.
Example
I get this message that the field is not filled in. However the code is working and there are random numbers showing up in the form. However it's not working when you click submit.
[Example 2 Code]
Related
I have an entity form (Entity A) which contains an subgrid to display linked records of another entity (Entity B), where multiple B records link to one A record.
Records of entity B are linked to entity A by clicking the '+' icon on the subgrid, filling out an quick create form for entity B and saving. After the save, the newly created record B shows up in the subgrid on the form of record A: all as expected.
When filling in the quick create form for entity B, a field containing an amount needs to be filled. After saving, a server side plugin fetches all records of entity B linked to the specific record of entity A, calculates the sum of all their amounts and fills the total amount in a field on the form of the record of entity A. This also works as expected, the newly calculated value is stored in the database. The problem is that the field that displays the total amount on form A does not refresh. It keeps on displaying the same amount it did when the form was loaded and only updates after a full page refresh. The value though, is updated every time a new record of entity B gets linked. The value on A only shows it's 'new' value when the page is refreshed.
The problem is that the users link 10+ records of B in a row, without refreshing. We get the request to make the field refresh automatically quite a lot, but i have no idea if this can be done, so: Is it possible to refresh (/re-render) a field on the form of entity A on the on save event of entity B? I presume this has to be done in javascript, since it is the client side representation of the fields value and the field value is already correctly stored in the database.
Thanks!
Using JavaScript, there is a grid refresh event you can subscribe to. From there you have a couple options.
In the refresh event you could trigger a rest call to retrieve the value from the server, and then update the value on the form. I'd also disable submit for the field as well, since you don't want the client updating it.
Or- Call save explicitly. You'd either have to ensure the form is valid or change all required fields to no longer be required to allow the save to happen. The save event will return the updated value from the database and automatically update the form.
If you've never made a rest call before, the first option is probably harder, but IMHO, it is the better option.
If helps. it can be done in C#. You can make plugin using the logic you described here.
That plugin would be registered using Plugin Registration Tool. you would have to add two steps for Entity B. First one would have Create message, and the second one Update. For the second step you would select just the amount filed update, so it is triggered only when that filed is updated.
It can also be done using Rollup Fields. They can be updated on click, but also have automatic update on every 12 hours, if that is frequent enough for you.
I don't have an idea how to do it using JavaScript, but i am new in CRM, so someone else might appear with that type of solution, I would also be glad to read it.
The easiest solution I can think of would be to poll the value by adding a new handler to entity A's form OnLoad event.
The code would then employ setTimeout to constantly read the value of the field from the REST API, compare the content of the field, and if it's changed it would invoke Xrm.Page.data.refresh to asynchronously reload the form without a full page reload.
Another (IMHO better) option: upgrade to a more recent version. Starting in 2015 Update 1, subgrids have OnLoad event too: you just need to handle that, invoking Xrm.Page.data.refresh without the weight of repeatedly pinging the server.
Variations of this questions have been asked before, but I haven't been able to fix it for the way I set my website up.
Basically, I have a website where the user can create a project. The user can add as many tasks to this project as he wants to, and each task has a number that adds to a total sum at the end. Usually, the Javascript function (TotalSum()) that I developed for this calculation works perfectly, but some users want to be able to use the Enter key to submit the form. While it does indeed submit the form as you'd expect, it doesn't launch the calculation function and instead skips straight to the submission of the form. This leads to numbers being submitted that may no longer be accurate to calculations.
TotalSum() is launched after a number input field is altered and the user either clicks out, clicks on the 'Submit' button or whatever else you'd expect – all except for the automatic submission via the Enter key.
My intent is to only allow submission of the form after the function has finished calculating and filled all the input fields with the new numbers. How could I best go about doing that?
I've tried various ways to go about this, but usually preventing the form from submitting also seems to stop me from submitting it again.
$('#form_project').submit(function (e) {
TotalSum();
// TotalSum(); is done calculating, proceed with submitting the form away!
});
I could also use PHP to just do the calculation after the form is submitted, but coding in PHP what Javascript is already doing fine by itself, if it was properly allowed to finish calculating by the Enter key, just seems like a messy solution.
jQuery is absolutely an option. How could I best go about doing this?
You can use jQuery for this purpose and check if the enter key is pressed using
$(document).keypress(function(key) {
if(key.which == 13) { // 13 is ascii for enter key
//Use your totalSum function
TotalSum();
}
});
I am using Adobe Livecycle ES2. My code is fine but all my validations are being displayed as a list in one single message box and that's not what I want. I want them to display after the user leave each field that's being validated. I tried solution like File>Form Properties> Form Validation but I don't have the Form validation option. I am wondering if I can get it to work by javascript coding.
You can add field-specific JavaScript code to the exit event for each field. If the user enters a value that doesn't pass the validation, you can then script something (a messagebox, an alert popup or some text) to appear as the user tries to leave the field.
You may want to use softer coded validation (which warns the user that the field isn't correctly completed but still allows them to move elsewhere in the form) in the exit event and use harder/stricter validation at the end of the form, for example, before the form is submitted) so that the user can't submit the form without completing the necessary fields but they can still progress with later fields even if the earlier fields aren't complete.
I'm working on a process in IBM BPM. In my coach I have a form with search and clear buttons. Search will be done using two string fields and a date while the result is a list. In clear script I defined a new instance of all variables in the form. for first time search is working but after pressing the clear button, search result is not correct. Any idea how can I clear my form or refresh it?
I would suggest you to do the following:
Bind the variables to the controls in coach view.
On click of clear button, attach a script in which you set these value to nothing. For example, if the variable is string set it as tw.local.somevariable = "".
Route back from script to coach.
I think this will work.
Apart from that, for your error, please check the values of the variable in debug mode.
I created only 1 form with some input fields in it, so this should be document.forms[0]. Now looping through the form elements, it gives me some results, which is fine, but after that the loop wants to carry on instead of stopping at the 1 and only form in the page. Obviously, it can't find any other form on the page other than the single one, so it give a console error...
Can someone please tell me why the loop doesn't wanna stop at the only form on the page?
Please check this jsFiddle link: http://jsfiddle.net/sxfmN/
Many Thanks