I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Create a Custom Field of type Select and label "Naming Series" for Item doctype. Specify possible Naming Series options in the Options field, separated by newlines. Also, mark it Mandatory.
The next part is a trick.
Via the browser's address bar, go to yourdomain/app.html#Form/Property Setter/New Property Setter 1
Save a property setter with the following values, without the double quotes:
DocType or Field = "DocType"
DocType = "Item"
Property = "autoname"
Property Type = "Data"
Set Value = "naming_series:"
Go to Tools (last icon on the top bar) > Clear Cache & Refresh.
Try saving a new Item. It should take the correct series.
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
Thanks for your reply. I’m sure that would work, but I would perfer the user be able to overwrite the automatically generated value. So for that reason I don’t want this action to happen on save, but in reaction to a button press. I don’t think your solution is amenable to this as it automatically sets it on save, not under script control.
If I could extract a list of existing IDs I think this would be the most generic solution, but I’m unsure how to extract this from the database.
Regards,
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Thanks for your reply. I'm sure that would work, but I would perfer the user be able to overwrite the automatically generated value. So for that reason I don't want this action to happen on save, but in reaction to a button press. I don't think your solution is amenable to this as it automatically sets it on save, not under script control.
If I could extract a list of existing IDs I think this would be the most generic solution, but I'm unsure how to extract this from the database.
Regards,
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
That looks almost what I need. I am running this on a hosted system though, so I need to do this with a client side script. I think your code snippet is for a server side script? I’m not really familiar enough with this to know how to translate that to the client side. Is that possible?
Regards,
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
That looks almost what I need. I am running this on a hosted system though, so I need to do this with a client side script. I think your code snippet is for a server side script? I'm not really familiar enough with this to know how to translate that to the client side. Is that possible?
Regards,
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Can you see any issues with this as I just get a blank.
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Can you see any issues with this as I just get a blank.
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
Can you see any issues with this as I just get a blank.
MarkW
On Wednesday, April 24, 2013 9:32:11 AM UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
Thanks to everyone who responded. Your last questions pointed me in the right direction. The routine was returning the correct value and populating the field, but the display wasn’t updating. I don’t think the line of code following the callback function was being executed. When I put the “refresh_field” call inside the callback “cur_frm.refresh_field(“item_code”);” it worked as expected.
Regards,
MarkW
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
OK not quite out of the woods yet. I thought I had got it for a while. The code provided works fine now, but I can’t work out how to change the pattern for LIKE to a variable so that I can return a result from the appropriate group. Since I couldn’t find this out I aslo tried to put the call & callback inside the switch statement , but that also returns syntax errors. Any ideas?
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
OK not quite out of the woods yet. I thought I had got it for a while. The code provided works fine now, but I can't work out how to change the pattern for LIKE to a variable so that I can return a result from the appropriate group. Since I couldn't find this out I aslo tried to put the call & callback inside the switch statement , but that also returns syntax errors. Any ideas?
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Yes, I got that, but the prefix needs to depend on which group the Item is in. I have this from the item_group field, but the pattern that LIKE is matching needs to be a variable to accommodate this.
The not updating was my fault, there was another code line later that was reverting the value back.
Regards,
MarkW
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Yes, I got that, but the prefix needs to depend on which group the Item is in. I have this from the item_group field, but the pattern that LIKE is matching needs to be a variable to accommodate this.
The not updating was my fault, there was another code line later that was reverting the value back.
Regards,
MarkW
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can't find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
It assumes that the item group has already been selected and that the group name has a prefix of the form"XXX-". The script extracts this prefix and uses it to search for the item with this prefix that has the highest suffix (XXX-YYYYYY). It Increments the suffix by one and populates the item code box with this.
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
On Wednesday, 24 April 2013 09:32:11 UTC+1, MarkW wrote:
Hello all,
I am trying to create a script that populates the Item ID, when creating a new item, with the next available number in a sequence. I have a script attached to a button on the item master page that runs correctly and extracts the item group, forms a new ID and updates the ID field.
What I need now is some information on how to get the next sequence number. I can think of two ways of doing this (1) iterate through all of the already created items to find the highest number or (2) use a naming series and have it give me the next number in the series.
I think #2 would be preferable, but I can’t find any information on how to go about doing either. Can any of you experts help with this information?
Regards,
MarkW
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.