# Reformat - replace on all the fields

**URL:** <https://forum.cloverdx.com/t/reformat-replace-on-all-the-fields/1764>\
**Category:** CloverDX Platform\
**Created:** [June 22, 2016, 12:00am UTC](https://forum.cloverdx.com/t/reformat-replace-on-all-the-fields/1764 "2016-06-22T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggg\_123](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@ggg\_123](https://forum.cloverdx.com/u/ggg_123)\
**Post date:** [June 22, 2016, 12:00am UTC](https://forum.cloverdx.com/t/reformat-replace-on-all-the-fields/1764/1 "2016-06-22T00:00:00Z")

</div>

In the reformat I want to do a replace on all the fields in one go:  
Say for example,

```auto
function integer transform() {
$out.0.* = replace($in.0.*,"abcdefg","abc");
return ALL;
}

```

But when I use the above code it throws error as “Function replace(string,string,string) is not applicable for the arguments (record(TRN\_045\_ROL\_TYPE),string,string)”.

Can you pls help me on this?

---

<div class="post-metadata">

**Author:** ![PedroVazquezRosario](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PedroVazquezRosario](https://forum.cloverdx.com/u/PedroVazquezRosario)\
**Post date:** [June 23, 2016, 7:52pm UTC](https://forum.cloverdx.com/t/reformat-replace-on-all-the-fields/1764/2 "2016-06-23T19:52:05Z")

</div>

Hi,

You can try the following code example, it will let you replace all fields in go:

```auto

// Transforms input record into output record.
function integer transform() {
	integer count = 0;
	
	while(count < length($in.0))
	{
	
	setStringValue($out.0.*,count,replace(getStringValue($in.0,count),"abcdefg","abc"));
	count++;
	}
	return ALL;
}

```

Cheers,

---

<div class="post-metadata">

**Author:** ![paulhbartosik](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@paulhbartosik](https://forum.cloverdx.com/u/paulhbartosik)\
**Post date:** [December 5, 2017, 7:42pm UTC](https://forum.cloverdx.com/t/reformat-replace-on-all-the-fields/1764/3 "2017-12-05T19:42:25Z")

</div>

As you see from the error message:

Function replace(string,string,string) is not applicable for the arguments (record(TRN\_045\_ROL\_TYPE),string,string)".

You cannot change all of the fields in one single operation. You will have to step through the fields one by one.

Try:

```auto
//#CTL2
// Transforms input record into output record.
integer columncounter;

function integer transform() {
   /* first copy all fields */
   copyByPosition($out.0,$in.0);
/* Then step through the fields */
   for(columncounter = 0; columncounter < length($in.0); columncounter++)
   {
   if (getFieldType($in.0, columncounter) == "string")  
      {
      setStringValue($out.0,columncounter, replace(getStringValue($in.0, columncounter),"abcdef","abc"));
      }
   } // end for next
   return ALL;
}

```
