Property Setting Sequence


Item property _aaa I setting sequence prefix=A- like A-0001, but I need _aaa can get another sequence prefix=B- like B-0001

Can I onBeforeAdd write  when (my logic) get sequence A-XXX or get sequence B-XXX?

  • Hi Michelle,

    I don't think you can set the property's data type as "Sequence" and then 'dynamically' decide, item per item, which sequence to use.

    What you could do is set the property's data type as "String" or "Text" and prevent the user from setting or changing it themselves (by disabling the field in the item form and - if you need more control - in some onBeforeUpdate method or some such). Then - as you yourself suggested - you can implement an onBeforeAdd method that gets the right value from the right sequence using the handy getNextSequence(System.String) in the Innovator class

    Say we have two sequences with names "sequence_a" and "sequence_b" that correspond to your sequences with prefixes "A-" and "B-", respectively. Also assume that earlier in the method, you ran some business logic to determine which sequence to use and this information is represented by the bool useSequenceA. You could then have something like the following:

    // Some business logic to assign bool useSequenceA
    Innovator inn = this.getInnovator();
    string currentValue = inn.getNextSequence(useSequenceA ? "sequence_a" : "sequence_b");
    this.setProperty("dynamic_sequence_prop", currentValue);

    return this;

    Note that, conveniently, getNextSequence() not only returns the current_value of the sequence, but also increments it by that sequence's 'step' on the sequence item. So you do not have to worry about doing that manually.

    I hope this helps a litte.