cancel
Showing results for 
Search instead for 
Did you mean: 

Updating a date field in syncbo

former_member188598
Contributor
0 Kudos

Hi All,

I want to update date field in my syncbo.

Plz suggest some way to do the same.

Thx in Advance

Priyanka

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you send to this methid the SyncBO Name, the Synckey, the new value and the column that you can modify... It will do it.


	public void modifyRowInDB(
		String syBName,
		String syncKey,
		String newValue,
		int col)
		throws SmartSyncException, PersistenceException {
		String syncBoName = syBName;
		// Set default Syncboname for this example in case value is null.		
		SyncBo syncBo = getSyncBoInstance(syncBoName, syncKey);
		SmartSyncTransactionManager transactionManager;

		// A transaction manager is valid for one action starting with beginTransaction and ending with commit/rollback
		// In this example we commit (save) every modification - no rollback.			
		transactionManager = dataFacade.getSmartSyncTransactionManager();
		transactionManager.beginTransaction();
		setHeaderFieldValue(syncBo, arrayHeaderFieldNames[col], newValue);
		//Commit the transaction		
		transactionManager.commit();
	}

Regards,

PS: i use this in MI 7.0

Edited by: Victor Capi on Apr 22, 2008 4:00 PM

Edited by: Victor Capi on Apr 22, 2008 4:01 PM

former_member188598
Contributor
0 Kudos

Hi Victor and Oliver,

Thx for the reply. I m using the same code for modifying SyncBo.

I have made my own DO class and within that i have used code for updating date as:

DateField dDate = vehicleRow.getDateField(fdDdate);

ddd = Date.valueOf(parmDdate);

dDate.modifyValue(ddd);

vehicleRow.modifyFieldValue(fdDdate,dDate.getValue());

But the value for date field is still null.....Its not taking the value i pass.

Suggest some help...

Regards

Priyanka

Former Member
0 Kudos

You should check the state of this row...


		try {
			SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(syncBoName);
			SyncBo s = dataFacade.getSyncBo(sbd, syncKey);
			if (!s.getStatus().toString().equals("S")) {
				MODIFY;
			} else {
				NO MODIFY;
			} 
		} catch (PersistenceException pex) {
			System.out.println(pex.getMessage());
			return false;
		}

Regards,

Former Member
0 Kudos

Hi,

if you would run into ther issue Victor checks - then you would receive an error - I guess you are not that far in the process.

I think what you are missing: you need to persist this setting as well - otherwise it is locally available in the memory, but whenever you read the data again it will show up with the old state.

Hope that makes sence ....

Regards,

Oliver

Answers (2)

Answers (2)

former_member188598
Contributor
0 Kudos

Hi All,

We have solved the prob by ourselves.It was smthing in the code.

Thanks for ur valuable time and suggestions.

Regards

Priyanka

Former Member
0 Kudos

Hi,

beside the code from Victor you need to develop the MODIFY handler in the backend and add it to the SyncBO definition in SBUILDER. Without the MODIFY handler you are not allowed to change any item on the client - even with the code from Victor. And do not forget to set the mapping in SBUILDER for the fields you would like to change.

This is for 7.0 - but in 7.1 it is the same, you just need the DOE instead of SBUILDER.

Hope that helps.

Regards,

Oliver