Skip to main content

Hi,

 

Scenario:

  • I have a SmartBox SmartObject which is used to store customer records.
  • Currently, I am using the ID field as a displayable reference number, so that the User can keep track of a particular record during a Workflow etc.

This works well in basic terms, as by default, K2 sets this field as an Autonumber (i.e. 1, 2, 3, ....). So will be unique (for that SmartObject).

 

Issue:

The reference is not unique across all smartobjects, a prefix is required within the reference number so that the User knows which type of record they are dealing with.

 

Requirement:

Amend the format of the Reference number.

The Reference Number should be prefixed and be a fixed number of digits. Examples: (FA00001, FA00002, FA00111).

 

Best Practice Query:

How would most people go about generating the Reference Number? 

 

Idea:

Would you get the ID back after the record has been created, then somehow generate the Reference Number using a Rule prehaps (?), then do an update on the Row storing the generated reference number?

 

Example:

  • Record is created with ID 63
  • ID is returned in Output Mappings
  • Then a Rule (?), to generate a Reference number of FA00063

 

Is the Rule part possible? I know how to do this in code (i.e. C#), but unaware of best way to do this K2.

 

I want to avoid doing any development outside of K2.

  • I'm using a SmartBox, so table is hosted in K2.
  • I'm aware a SQL trigger could be done against the K2 SmartBox Database table but trying to avoid that.

 

Thanks

Hi ConradMc,


 


If I'm understanding correctly, you may be able to accomplish this by doing the following:


1) Create two hidden data labels


2) Add a rule after the entry has been created, and add a SmartObject method action that runs a List method, that and use ID as the input mapping. Pass this ID to the first hidden data label in the output mappings.


3) Add a function on the form/view that appends the needed characters to that ID value (i.e. FA000 + [Data Label]).


4) Add another rule to output this function result to another data label. Use that on your Update SmartObject method.


 


The above steps will likely work if the reference numbers are static, but you will need to add some additional steps if this is going to be a dynamic value. Hopefully these steps make sense, but let me know if you have any questions or need clarification.



Regards,
Emily


Hi Emily,

 

Thanks for this, your solution is spot on.

 

I did a quick test whereby I hardcoded the value of one of the data labels.  I used the Concatenate function to output FA000999.

 

The only thing I need to do next is ensure that the number part is always 5 digits with the correct number of trailing zeros. I think I should be able to achieve this by utilising some of the additional Operators available.

 

Thanks!


Reply