Hi all,
I'm trying to build a sequence and using the year as a prefix.
After each year the sequence needs to restart a beginning with 0 or 1.
After running and debugging the script it will hang.
When starting a new action and click on save the following server method will start.
Innovator inn = this.getInnovator();
if (this.getAction() == "add")
{
//System.Diagnostics.Debugger.Break();
//Get the prefix of the sequence who needs to be reset every year
Item res_seq = this.newItem("sequence","get");
res_seq.setProperty("keyed_name","aer_action_8D");
res_seq = res_seq.apply();
string prefix_seq = res_seq.getProperty("prefix","");
//Get current year
string Year = DateTime.Now.Year.ToString();
Year = Year + "-";
//If the prefix isn't equal change the prefix and reset
if (prefix_seq != Year){
res_seq = this.newItem("sequence","edit");
res_seq.setAttribute("where","[sequence].name='aer_action_8D'");
res_seq.setProperty("prefix",Year);
res_seq.setProperty("current_value","1");
res_seq = res_seq.apply();
}
//Get next Sequence and use the field item_number to put it in.
string nextseq = inn.getNextSequence("aer_action_8D");
string item_number = this.getProperty("item_number", "");
this.setProperty("item_number",nextseq);
}
return this;
When the if statement is skipped it works, and when we skip the getNextSequence (putting the last three lines in comments) it works and it's changing the prefix correctly.
If tested and set prefix on 2014- and then running the script.
I hope some one has done something like this before and could help me.
Best regards,
Tom Hofste