cancel
Showing results for 
Search instead for 
Did you mean: 

Counter not working

Former Member
0 Kudos

Hi All,

I have 10 records in the same level and in each record there is a field "LineNumber" and this is a incremental field, I have used counter to increment it starting from 1, but in all the cases records the field value is "1", it's not incrementing. I have also tried an UDF, but it also gives the same result.

Do you have any clues????

Regards,

Bharani

Accepted Solutions (0)

Answers (7)

Answers (7)

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

As is replied earlier the issue is because of the context.

Do paste your source and target structure.

Also try this UDF.

Source(to get the no of occurance) ---> remove context ---> UDF -


> SplitByValue ---> Target

UDF(of type queue):

public void test1(String[] a,ResultList result,Container container)

{

for(int i=1;i<=a.length;i++)

{

String temp = Integer.toString(i);

result.addValue(temp);

}

}

Thanks

SaNv...

Former Member
0 Kudos

Check with the below UDF

use cache parameter value and no inputs to UDF

public String increase(Container container)
{
  //write your code here
i = i + 1;
 String c;
c  = Integer.toString(i);
return c;
 }

Here i is a global variable initialized to 0.(goto Edit java section fill in global variable section and initialization section)

increase--->target

Edited by: malini balasubramaniam on Sep 4, 2008 3:12 PM

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

Is the counter increment value is 1.

The problem might be because of the context level.

Can you paste the source and target structure that is used.

Thanks

SaNv...

hemant_chahal
Contributor
0 Kudos

Hey use this,

int inc=1;

Integer seqno=(Integer) container.getParameter("seqno");

if(seqno==null)

{

seqno = new Integer(1);

}

else

{

int number=seqno.intValue()+inc;

seqno=new Integer(number);

}

container.setParameter("seqno",seqno);

return seqno.toString();

thanks

hemant

Former Member
0 Kudos

Hi,

My UDF is same as one mentioned above, but I suppose there is not context change happening in the source, but still the UDF has to work atleast.

Is context change esential for UDF also.

Regards,

Bharani

hemant_chahal
Contributor
0 Kudos

I Dont think so that context change has some effect on the UDF.

If that has some effects please let me know also how.

thanks

Former Member
0 Kudos

Hi Prakasu,

But the counter is not related to any of the source field....

I have records...based on certain conditions records are populated

Record 1

-


counter -> LineNumberField

Record 2

-


counter -> LineNumberField

Record 3

-


counter -> LineNumberField

Record 4

-


counter -> LineNumberField

So I don't have the scope of changing the context anywhere.

Regards,

Bharani

Former Member
0 Kudos

Hi,

that time you can choose the option static function "index".Select in the properties Initial value '1', Increment '1' and count indices "Entire Document".

Record 1

-


Index -> LineNumberField

Record 2

-


Index-> LineNumberField

Record 3

-


Index -> LineNumberField

Record 4

-


Index -> LineNumberField

This will work for ur requirement.

Regards,

Prakasu

Former Member
0 Kudos

Hi,

I have tried the index function also but still it's 1 in all records.

What will be the Input to the index function?

Regards,

Bharani

Former Member
0 Kudos

Hi,

For the logic you applied for the create the records.

Regards,

Prakasu

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Bharani,

Instead of using a counter, you can use the Statistic Function called Index. It can also be manipulated to count contexts.

Hope this helps.

Regards

Former Member
0 Kudos

Hi,

Using counter we can achive your requirement.Its because of context problem.

Change the context parent node..

Like,

you have a structure,

<Node>

<Node1>

<Field>

Then change the context to Node.

Regards,

Prakasu

Edited by: prakasu on Sep 4, 2008 12:24 PM