New field with auto-increment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2015 01:09 PM
Hi everyone,
I created a field "Reference event" that I want to act similar to how Incident works with auto-increment with the prefix INC. I made a new prefix in Number Maintenance and added a business rule with a condition "current.event_reference.nil() and a script:
function onBefore(current, previous) {
current.event_reference = getNextObjNumberPadded();
gs.addInfoMessage("Created Incident " + current.event_reference );
}
The column in my table has the default value Next Obj Number Padded. When I go to my form, it is not showing a value at all. Anything else I should consider? Any help would be great, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2015 02:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2015 05:33 AM
Hi Venkat,
I checked the dynamic default value and it had Get Next Number, but I changed it to be Get Next Padded Number. Now when I view my form, I get an error up top that says getNextObjNumberPadded undefined, maybe missing global qualifier.
What else should I be looking for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2015 07:37 AM
Hi
The Number maintenance is set based on the table and if selected table is Incident then the increment is done for the INC counter for both fields.
I did try it on the demo013 instance on the incident form. See a field "Test" which is set to increment.
If you want to maintain its own counter then there are 2 options.
1. Create a new table to hold the number counters for the TEST field value.
2. If you dont want to create a new table, then everytime the incident is created a business rule should run to check all the incident records for the latest counter of TEST field and increment the counter using the regular count++ expression in business rule.
Please let me know if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2015 06:01 AM
Hey Venkat,
In the long run, I decided it would be actually be easier to extend the Incident table and re-label "Number" to "Reference Event" for my instance. Thank you for the tips though, I will keep them in mind if I do it again!
Eric