Auto Increment Problem

Ask your questions here.
Post Reply
aubergine1204
Posts: 14
Joined: 31 Aug 2021, 05:52
Name: Dean
Location: Melbourne, Australia

Auto Increment Problem

Post by aubergine1204 »

Hi,

I'm trying to use Numeric Input (php) to create a count for each task.
Ultimately I'd like the count to increment when a new task is generated in recurring tasks.

I have the following code for the field but it doesn't seem to be incrementing (using dynamic option for testing):

Code: Select all

$current_field_value = intval($current_field_value);

if(!strlen($current_field_value)){
    $incremented_value = 0;
  } else {
    $incremented_value = $current_field_value + 1;
}
$output_value = $incremented_value;
The $current_field_value is working ok but $output_value doesn't seem to be saving / updating.
Am I doing something wrong?

Thanks.
eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Re: Auto Increment Problem

Post by eddydeniro »

Just uncheck dynamic option because it will not store any value in that field.

You can simplify the code into this:

Code: Select all

if(!strlen($current_field_value)){
	$output_value = 0; //this 0 will be saved in the database in normal mode (non dynamic) after the record created
} else {
	$output_value = $current_field_value + 1; //this line will be executed on editing record
}
Try updating the same record several times to see if it's incremented.
aubergine1204
Posts: 14
Joined: 31 Aug 2021, 05:52
Name: Dean
Location: Melbourne, Australia

Re: Auto Increment Problem

Post by aubergine1204 »

Ok. That is working, thanks. But now I've found it doesn't suit my needs anyway.
I need something that will track the number of tasks created from specific recurring tasks.
The count as is, will set as 0 every time a task is created.

So it would need to read the count value or a template / master task (that new ones are generated from), then increment this value and apply to the newly created recurring task (and also then increment the template / master count value for next time).

I think I will put this in the too hard basket, but good to know the count feature is working for records when edited.

Thanks again.
Post Reply