none
Problem with removing department from Business Drivers RRS feed

  • Question


  • I created a business driver and selected two departments to associate
    it to. I am trying to create a "remove" action to programmatically
    remove one of the associations based on where I'm accessing the
    remove from (so I'm not exposing the departments field at that
    point).

    Removing DriverDepartmentsRow from DriverDataSet doesn't seem to work.
    I've tried:
    •    DriverDataSet.DriverDepartmentsRow.Delete() then
    DriverDataSet.DriverDepartmentsRow.AcceptChanges()
    •    DriverDataSet.DriverDepartments.RemoveDriverDepartmentsRow(deptRow)
    then DriverDataSet.AcceptChanges()
    •    Called the DriverClient.UpdateDriver(DriverDataSet)

    I've verified the count and contents of
    DriverDataSet.DriverDepartmentsRow.Rows to be 1 less after I do the
    remove/delete but when I re-query the row I removed is back. Is
    there another "commit" I am missing?

    Tuesday, February 9, 2010 4:07 PM

Answers

All replies

  • Hey,

    Can you privde a code snippet to repro the issue?

    Thanks,

    Chris
    Thursday, February 11, 2010 1:10 AM
    Moderator
  • Hi Chris,

    SvcDriver.DriverClient driverClient = PSIRouter.getServiceInstance<DriverClient>(_pwaUrl);
    driverClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

    SvcDriver.DriverDataSet dsDriver = new SvcDriver.DriverDataSet();
                        dsDriver = driverClient.ReadDriver(driverUid);

                        //driverDataSet.DriverDepartments.FindByDRIVER_UIDDEPARTMENT_UID(driverUid, portfolioDept).Delete();
                        Log.MainLog.Debug("===>Before remove - driverDataSet.DriverDepartments.Rows.Count: " + dsDriver.DriverDepartments.Rows.Count);
                        SvcDriver.DriverDataSet.DriverDepartmentsRow deptRow = dsDriver.DriverDepartments.FindByDRIVER_UIDDEPARTMENT_UID(driverUid, portfolioDept);
                        Log.MainLog.Debug("===>Found deptRow: " + deptRow.DEPARTMENT_NAME);
                        dsDriver.DriverDepartments.RemoveDriverDepartmentsRow(deptRow);
                        //driverDataSet.DriverDepartments.AcceptChanges();
                        //driverDataSet.AcceptChanges();                   
                        Log.MainLog.Debug("===>After remove before update - driverDataSet.DriverDepartments.Rows.Count: " + dsDriver.DriverDepartments.Rows.Count);
                        driverClient.UpdateDriver(dsDriver);

    I commented out the AcceptChanges() in the code (one at a time) but I've also brought them in before the UpdateDriver() but that throws a concurrent update exception.  After this snippet I re-set the dsDriver to do another driverClient.ReadDriver(driverUid) call but the dsDriver.DriverDepartments.Rows.Count is back up to the count before the remove.

    Thanks,
    Rhea
    Thursday, February 11, 2010 4:04 AM
  • Hey,

    Try row.delete() instead of RemoveDriverDepartmentRow.

    Chris
    Friday, February 12, 2010 4:04 AM
    Moderator
  • Chris,
    Sorry I commented it out of the snippet but I also tried row.delete() instead of RemoveDriverDepartmentRow (see original message) and it did not work.

    Rhea
    Friday, February 12, 2010 6:21 PM
  • Hey,

    Try row.delete() instead of RemoveDriverDepartmentRow.


    Could you give more details?
    Friday, January 21, 2011 6:11 AM