anchor.diff:                      $('#listOfCompany option:contains("' + newProduct.company.name + '")').prop('selected', 'selected');
                       var company = new Object();
                       var id = newProduct.company.id;
  -                    id=parseInt(id);
  -//                    var test =getAllDepartment(id);
  -//                    test.then(function(newProduct){
  -//                        console.log(newProduct);
  -//                        $('#listOfDepartment option:contains("' + newProduct.department.name + '")').prop('selected', 'selected');
  -//                        window.location.href = "#productForm";
  -//                    })
  -
  -                    $.when(getAllDepartment(id)).done(function(  ) {
  -//                        console.log(newProduct);
  -//                        $('#listOfDepartment option:contains("' + newProduct.department.name + '")').prop('selected', 'selected');
  -                        window.location.href = "#productForm";
  -                    });
  -
  +                    id = parseInt(id);
  +                    getSelectedDepartment(id, newProduct.department.name);
  +                    window.location.href = "#productForm";
                   }
   
                   /* Load Company data to select box data using ajax */
  
positive.code:                     });
                  }
  
  
                  /* Load Department data to select box data using ajax */
  
                  function getAllDepartment(companyId) {
                      $('#listOfDepartment').empty();
                      $.ajax({
                          headers: {
                              'Accept': 'application/json',
                              'Content-Type': 'application/json'
                          },
                          'type': 'POST',
                          url: 'http://localhost:8080/department/departmentListByCompany',
                          'data': JSON.stringify(companyId),
                          'dataType': 'json',
                          success: function (data) {
                              var collaboration;
                              collaboration += '<option id="defaultOptDepartment" value="0">Select Department</option>';
                              $.each(data, function (i, d) {
                                  collaboration += "<option value=" + d.id + ">" + d.name + "</option>";
                              });
  
                              $('#listOfDepartment').append(collaboration);
                          },
                          error: function (e) {
                          }
                      });
                  }
  
  
                  /* Load Department data to select box at edit time */
  
                  function setOptionVal(id, data) {
                      $('#listOfDepartment').empty();
                      console.log(data);
                      var collaboration;
                      collaboration += '<option id="defaultOptDepartment" value="0">Select Department</option>';
                      collaboration += "<option value=" + id + ">" + data + "</option>";
                      $('#listOfDepartment').append(collaboration);
                  }
  
  
              });
              //
  
  
negative.code:                 };
  
  
  
  
                  /* Load Department data to select box data using ajax */
  
                  function getSelectedDepartment(companyId, obj) {
                      $('#listOfDepartment').empty();
                      $.ajax({
                          headers: {
                              'Accept': 'application/json',
                              'Content-Type': 'application/json'
                          },
                          'type': 'POST',
                          url: 'http://localhost:8080/department/departmentListByCompany',
                          'data': JSON.stringify(companyId),
                          'dataType': 'json',
                          success: function (data) {
                              var collaboration;
                              collaboration += '<option id="defaultOptDepartment" value="0">Select Department</option>';
                              $.each(data, function (i, d) {
                                  collaboration += "<option value=" + d.id + ">" + d.name + "</option>";
                              });
  
                              $('#listOfDepartment').append(collaboration);
                              console.log("testing....");
                              $('#listOfDepartment option:contains("' + obj + '")').prop('selected', 'selected');
                          },
                          error: function (e) {
                          }
                      });
                  }
  
  
                  /* set selected row data to product form for edit */
  
                  function setDataToProductForm(newProduct) {
                      document.getElementById('productForm').style.display = "block";
                      $("#updateProduct").show();
                      $("#saveProduct").hide();
  