# Reformat: incorrect value saved in target field

**URL:** <https://forum.cloverdx.com/t/reformat-incorrect-value-saved-in-target-field/435>\
**Category:** CloverDX Platform\
**Created:** [November 13, 2008, 12:00am UTC](https://forum.cloverdx.com/t/reformat-incorrect-value-saved-in-target-field/435 "2008-11-13T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![achan](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@achan](https://forum.cloverdx.com/u/achan)\
**Post date:** [November 13, 2008, 12:00am UTC](https://forum.cloverdx.com/t/reformat-incorrect-value-saved-in-target-field/435/1 "2008-11-13T00:00:00Z")

</div>

Hi,

============ my input FMT ==================  
…  
  
  
…

============ my input data ==================

ITEM\_ID, COST  
1, 10.00  
2,  
3, 30.00

============ my output FMT ==================  
…  
  
  
…

========================================

my transform method in my transform class:

public boolean transform(DataRecord \_source, DataRecord \_target)  
{  
DataRecord source = \_source[0];  
DataRecord target = \_target[0];

Iterator fields = source.iterator();

while (fields.hasNext()) {

DataField sourceField = fields.next();  
String fieldName = sourceField.getMetadata().getName();  
Object value = GetVal.getDouble(source, fieldName);

if (value != null && value.toString().length() \> 0) {  
String temp = value.toString();  
SetVal.setString(target, fieldName, temp);  
}  
}

return true;  
}

the output result:  
ITEM\_ID, COST  
1, 10.00  
2, 10.00  
3, 30.00

the COST for ITEM\_ID #2 is NOT supposed to be 10.00, it should be blank… looks like it is taking the value from the previous record (COST from ITEM\_ID #1) if i do not explicit set the value to blank in my transform method…

this is incorrect… is there an internal buffer that CloverETL uses for record field values that is not being cleaned up properly?

so my workaround is to add this to my transform method:  
if (value == null || value.toString().length() == 0)  
SetVal.setNull(target, fieldName);

but i am still puzzled by why when a field value is not set for a current record, it takes the value from the previous record??

thanks,  
al

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [November 13, 2008, 8:07am UTC](https://forum.cloverdx.com/t/reformat-incorrect-value-saved-in-target-field/435/2 "2008-11-13T08:07:20Z")

</div>

Hello,  
it’s really bug. For the meantime add:

```auto
target.reset();

```

before getting iterator.  
The fix will be in nearest release.

---

<div class="post-metadata">

**Author:** ![achan](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@achan](https://forum.cloverdx.com/u/achan)\
**Post date:** [November 13, 2008, 5:00pm UTC](https://forum.cloverdx.com/t/reformat-incorrect-value-saved-in-target-field/435/3 "2008-11-13T17:00:00Z")

</div>

Hi Agata,

sounds good…

Thanks 🙂

al
