Hide and display a picklist on onchange of lookup - dynamics-crm-4

I have one field on Form of MS CRM 4, which should be hidden by default and should only be visible on selecting a specific value of lookup
I used crmForm.all.gsk_roles_c.style.display = '' on onchange event of lookup
The issue is field is hidden but values are still populating on screen without onchange event

To hide field you should use code
crmForm.all.gsk_roles_c.style.display = 'none';
crmForm.all.gsk_roles_d.style.display = 'none';
To show field you should use code
crmForm.all.gsk_roles_c.style.display = '';
crmForm.all.gsk_roles_d.style.display = '';

Related

Prevent deletion of checkbox in sheet editable by many users

I am using checkboxes in a sheet (and their functionality in themselves are exactly what I need).
The problems I am having is that the users who are able to edit the sheet, sometime (by mistake) delete the checkbox instead of simply checking/un-checking the checkbox.
Hence, I want the users to use the checkboxes, but not be able to delete them.
Is this possible somehow?
FYI: it is not possible to use Google Forms in the case.
Here you have an example on how to achive it using onOpen triggers
function onOpen(e)
{
var range = SpreadsheetApp.getActive().getSheets()[0].getRange(1,4,5);
var values = range.getValues();
for ( var val in values ) {
if( values[val] != true && values[val] != false ) {
values[val]= false;
}
}
range.insertCheckboxes(values);
}
You have to specify where are the checkboxes placed, in the code example provided there are 5 of them, starting from row 1 to row 5, and they are placed on the 4th column, so called D.
This is specified on the getRange(1,4,5) function:
getRange(InitialRow, Initial Column, Number of Rows)
for more documentation around the use of getRange() use the following reference.
This onOpen function will be executed every time that the spreadsheet is opened, and if on the specified fields there aren't false or true statements, it means that we lost the checkbox somehow, so it will introduce them again.

How can I get disabled inputs in Post

I am using the Google Address Autofill to populate some disabled inputs on the form. The idea is that
The user can see the data I am going to save (because not every field returned by Google is saved).
And they can not interfere with it and give an invalid mismatched set of fields.
Because the inputs are disabled, I cant see them in $POST when the form is submitted. I could mirror each field onto a hidden but enabled input. Is there a cleaner way to do this ?
You could collect them using javascript and add them to the url of the next form and attach it to the button.
You can enable them via javascript when the form is submitted. Give your form an ID, I've called it formId below, and then add the following right before your closing </body> tag
<script>
var form = document.getElementById('formId').addEventListener('submit', function(e) {
e.preventDefault();
var inputs = document.getElementsByTagName('input');
for (var i = 0; i<inputs.length;i++) {
inputs[i].setAttribute('disabled',false);
}
this.submit();
for (var i = 0; i<inputs.length;i++) {
inputs[i].setAttribute('disabled','disabled');
}
});
</script>

Dynamically Fill in form from drop down selection

I have the Following Form:
How do i do the following:
When I chose a user from the select user drop down menu, After selecting the user I want to dynamically fill in the data below ? How do I do this without refreshing the page or loading another page?
I am using ASP.NET MVC
I would have to get the User ID from the Select User and then get the appropriate roles from the model
You could use AJAX. Subscribe to the .change event of the DropDown, retrieve the selected value, perform an AJAX call to a controller action sending the selected value which will return as JSON the corresponding list. Then in the success callback of this AJAX call add the necessary information to the lists.
Something along the lines of:
$(function() {
$('#id_of_your_users_ddl').change(function() {
var selectedValue = $(this).val();
var url = $(this).data('url'); // this assumes that you have appended a data-url attribute to your dropdown
$.post(url, { userId: selectedValue }, function(result) {
// result will be a JSON list returned by your controller action
// that you could use here to update your roles lists
});
});
});

how to select the checked checkbox rows

I have a table form mysql in my html page, and each row has a checkbox, if I checked some checkboxes , how could I output the rows I checked.
now I konw how to output all the rows, but I don't konw how to selected the rows I checked
give all the check boxes the same name and assign each one with a different value, say the rows primary key.
Use request.getParameterValues() in the servlet and you will get an array which will have only the checked values
Have more you can get checked table rows in javascript. Examples:
var allRows = $('#yourTableId tr');
for(var i=0; i<allRows.length; i++) {
if(allRows[i].find('input:checkbox').checked) {
//selected row allRows[i]. And you can get value checkbox allRows[i].find('input:checkbox').value
}
}
or use each loop jquery:
$('#yourTableId tr').each(function(index)) {
if($(this).find('input:checkbox').checked) {
//selected row $(this). And you can get value checkbox $(this).find('input:checkbox').value
}
}
And have more answers in stackoverflow for such issues:
Using jquery to get all checked checkboxes with a certain class name
Jquery find a checkbox inside a table row
How to check whether a checkbox is checked in jQuery?

Is it possible to change the value of a callBackElement from within a handler function?

I have a handler function that is updating a quite large UI with values from a spreadsheet. The rowindex of the sheet comes from a callbackElement as e.parameter.hidden (hidden is the widget that holds the value) and that I increment/decrement in the function.
I have another handler function that searches the spreadsheet for a string value and returns a rowindex that I assign to this same hidden widget.
If I trigger the 'search' handler first and then the 'display' handler, I have my UI updated with the 'found' data, which is nice but needs two separate clicks on two distinct buttons.
Now my question : how could I include in the 'search handler function' a call to the 'display handler' and pass all e.parameters BUT modify the value of the e.parameter.hidden only ?
I know e is an object with a lot of keys and values but I don't know how to manipulate just one value in there...
The code of the search handler is very short and goes like this :
function findname(e){ // this function is called by a handler triggered by a keypress on a textBox
var app = UiApp.getActiveApplication();
var hiddenD = app.getElementById('hiddenD');
var str = e.parameter.find ; // find is the textBox's name
var found = point(str);// point() is a function that returns the rowindex of the found value
hiddenD.setValue(found);// hiddenD is the hidden widget that I want to 'manipulate'
nextitem(e);// nextitem is the function that updates the UI and that is normally called by a handler on another button
return app
}
Well I hope this question is clear enough (this wasn't easy to explain), if not please ask ;-)
e is just a json data which you can manipulate by its key.
Code skeleton is like
searchHandlerFunction(e){
//Your all other sttements
//Assign the new value to hidden parameter
e.parameter.hidden = <your new value>;
DisplayFunction(e);
}
Why don't you simply store the rowIndex as a CacheService property ? I'm using this with a lot of success in lieu of hidden fields and hidden text boxes.
You can call them from anywhere and modify them anywhere.