I have a newform that sets values on selection of a dropdown value in other fields on form. eg. I select a value in ID dropwdown and all the field values related to that selection are prefilled in other fields on newForm.

Now this newform has two dropdowns that are cascaded Lookups. Function and based on its selection -category.

But while prefilling category field is not getting filled. so I used below code to achieve that.

var checkcategory = ListItem.get_item("ProblemCategory").get_lookupValue();
//var pc_before = $("select[title='ProblemCategory']").val();   alert(pc_before);
$("select[title='ProblemCategory']").prepend('<option value='+checkcategory+'>'+checkcategory +'</option>');

var pc_after = $("select[title='ProblemCategory']").val(); alert(pc_after);

var allOptions = document.querySelectorAll("[title=ProblemCategory] option");

[].some.call(allOptions, function(option) {
if (option.innerHTML == checkcategory ) {
    option.selected = "selected";
    return true;

But this is not allowing to commit the data and save the form. as Category value is giving as '0' when checked in alert statement. Can someone help please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.