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.
Related
So, we have an existing app, which I think is built on sapui5 if I am not mistaken. It's pretty much a simple search function app. I reviewed the DOM and noted that the search box form has the ID of #__xmlview0--searchField-F, and the search box container including all is under #__xmlview0--searchField and the actual text entry area is under #__xmlview0--searchField-I. Essentially, it looks something like this - highly simplified:
<div id = "__xmlview0--searchField">
<form id = "__xmlview0--searchField-F">
<input type = "search" id = "__xmlview0--searchField-I" />
<div id = "__xmlview0--searchField-search"></div>
</form>
</div>
There are two pages that I am interested in, one is the original start page for searching, and the other is the search page with results displayed, which also contains the same search box so that users can quickly perform another search. Lets call these start page and results page.
Since the app doesn't seem to take any QS for search strings, I was wanting to create a nested page where I can simply pass on the elements of searching into the app generated page, and display search results with one click, instead of having the users need to do them manually and transcribe things from one place to the search function.
I have attempted initially to simply change the value of the search box and then submit the search:
$("#__xmlview0--searchField-I").val("SOMETHING");
$("#__xmlview0--searchField-F").submit();
Such approach did not work. It appears that the submit will execute for the start page, but will not for the results page. But even with the start page where submit executed, the search text of "SOMETHING" has been lost for sure somehow. So I tried typing in text manually and only doing:
$("#__xmlview0--searchField-F").submit();
Which seems to show the submit button working (also only for start page, not for results page), though it appears that "SOMETHING" is still lost somehow even though I manually entered the text when executed in start page. Thinking something may be wrong with clicking the submit mechanism programatically, I tried only doing:
$("#__xmlview0--searchField-I").val("SOMETHING");
and then manually click the search execution icon (also tried pressing "enter"). But to my dismay, despite the DOM display the changes for the input search field properly, the search did not execute though the button blinked so I am sure I properly clicked it at least.
So I thought, maybe I need to trigger some kind of event before I start making changes to the search field to prompt proper event execution behind the scenes so that the input text will be recognized properly when changed:
$("#__xmlview0--searchField-I").focus();
$("#__xmlview0--searchField-I").val("SOMETHING");
$("#__xmlview0--searchField-I").focus();
$("#__xmlview0--searchField-F").submit();
But that did not work either. I am pulling my hairs out trying to figure out what may be going on. Can someone who knows the SAPUI5 stuff give me some insight? Am I doing something that is simply not possible under this environment?
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.
So I'm working on a chat system and even though I know it works in a pretty lame way - submitting messages in a new window () - I'm interested if there's any way to reset the textarea's content after sending the message.
Now, the problem is, I've even actually found ways to do so via JavaScript (editing the textarea's value), but I don't know how to "launch" the javascript after submitting the form.
Obviously, I can just use onSubmit(), but that delete's the value BEFORE sending the data. So it works, but sends an empty text.
Any ideas?
Thanks!
A common solution is to copy the values of your <form> into an object which you can then convert to JSON. That way, you have a copy of the values which doesn't change when you reset the fields of the form. jQuery will make this very simple. See also: serializing and submitting a form with jQuery POST and php
The second solution is to submit the form and as the last thing, add a timeout which resets the form. But there will be a small gap and a user might be able to type while your handler is clearing the form.
Okay, so I've used a JavaScript timer to run the clearing function 300 ms after clicking the submit button. Works. Thanks all :)
I have an application with an input field that takes a dollar value. I need to change the way this dollar value displays so that the number is formatted with a $ and commas, like $5,550.00 if the user just enters 5550.
I found a way to do this, but doing so causes all hell to break loose in the code that uses the value from this field--it does a bunch of stuff, including database updates that break if given $5,550.00 instead of 5550.
There is a TON of underlying code and I am not empowered to go fix it all. I need to figure out a way to display this value to the user as $5,550.00 but keep the underlying value as 5550.
Any suggestions?
Use 2 text inputs. A "façade" one that the user sees, and a "real" one which is actually submitted to the server with the form. When the user enters text into the visible input, you can use JavaScript to set whatever corresponding value you want into the "real" (hidden) input. That effectively decouples the displayed value from the submitted one. You can even use a plugin such as jQuery Masked Input to do the front-end number formatting for you.
Make sure to only apply this when JS is enabled in the browser, otherwise your form will be broken with JS disabled.
If you are talking about an HTML form, I would submit the form using javascript.
You could revert the value back to unformatted before submitting the form.
I'm trying to detect when a browser places a saved username and password into the input fields. I've looked at this post , but I don't have the option to change this functionality, and the other solutions on don't work.
Basically, I have a disabled login button if the fields are empty on load. But when a browser fills in the input, it doesn't enable the button. I'm trying to find how to see if it changes.
I'm using jQuery and JS.
I've tried .change, on .ready, on .load, and all. It seems to happen after the .load event.
Does anyone know a solution to this? I would like to avoid using any sort of timeout.
I think there is no way to detect if the browser has some buil-in feature that pre-populates the fields.
You could solve the problem with the a timer that enable the button, if something is there.
Something like this:
setInterval(function (){
if($("#username").val()!=""){
$("#loginbutton").attr("enabled","enabled");
}
},1000)
The key thing is that the field will be populated without there having being any keypresses in the field.
So if you trap .keypress on the input field to know if a key is any pressed, then if you get to submitting the form and find there were no keypresses despite a value being there - then you can be somewhat sure that the browser pre-populated it.
If you want to know before submitting (soon after the page loads), you'd want to run a check on an interval that sees if the value has changed despite no key presses.
As #japrescott pointed out, you might want to check for .focus as well in case the user pastes a value in.
Haven't test this, but couldn't you simply compare the default values of each field to the values of each field after the page is loaded (or .2 seconds after the page is loaded if that's an issue)?
Give a shoot to Jquery .live() function
$('.element').live('load', function(){
enableLogin();
});