Ron - Thursday, April 26, 2007 12:00 PM:
We have a requirement where the issuing of ID numbers is to be automated, but sometimes we must enter the number manually. I have no problems configuring Innovator for sequenced numbering, but then then no manual override is possible. Is there a way to allow either/or?
Thanks
Ron
RobMcAveney - Thursday, April 26, 2007 1:11 PM:
Hi Ron -
The easiest way to do this is to make the property a 'string' (instead of a 'sequence') and create a simple UI to fill in the property with an auto-generated number. To do this, create an HTML field on the form and enter the following in the HTML Code (and replace 'Default Part' with the name of your Sequence) :
<script>
function getNumber() {
var newNum="";
newNum=top.aras.getNextSequence('','Default Part');
newNum = newNum + document.forms[0].name.value;
handleItemChange("item_number", newNum);
}
</script>
<a href="BLOCKED SCRIPTgetNumber();"><img src="../images/icons/16x16/16x16_sequences.gif" border="0" ></a>
Rob
RobMcAveney - Thursday, April 26, 2007 1:17 PM:
In the above, replace "BLOCKED SCRIPT" with "javascript" and then a colon -- I guess the forum is configured to block that text.Ron - Thursday, April 26, 2007 2:07 PM:
I tried this but I am getting an error "error line 208 'Re_Reports' is undefined
Here is what I used
<script>
function getNumber() {
var newNum="";
newNum=top.aras.getNextSequence('',Re_Reports);
newNum = newNum + document.forms[0].name.value;
handleItemChange("item_number", newNum);
}
</script>
<a href="BLOCKED SCRIPTgetNumber();"><img src="../images/icons/16x16/16x16_sequences.gif" border="0" ></a>
I have a sequence defined as Re_Reports
RobMcAveney - Thursday, April 26, 2007 2:34 PM:
You need quotes around Re_ReportsRon - Thursday, April 26, 2007 2:40 PM:
Now that was just too simple......
Thanks it works great.
Ron
Ron - Thursday, April 26, 2007 3:21 PM:
Hi Rob
Is there a way to disable the select action after the user has selected newNum. I have looked at the field event but not sure what code to use to disable this field after click.
Thanks
Ron
RobMcAveney - Thursday, April 26, 2007 4:07 PM:
Ron -
The easiest way is probably just to hide the button after it's been clicked once, like this:
<script>
function getNumber() {
var newNum="";
newNum=top.aras.getNextSequence('',"Re_Reports");
newNum = newNum + document.forms[0].name.value;
handleItemChange("item_number", newNum);
document.getElementById("seqButton").style.display="none";
}
</script>
<a id="seqButton" href="BLOCKED SCRIPTgetNumber();"><img src="../images/icons/16x16/16x16_sequences.gif" border="0" ></a>
Rob
Ron - Thursday, April 26, 2007 4:31 PM:
Yes it works fine, now the user can only get the number once. Now the next question can the Document number field be locked to prevent the user from over writing the seq. number?
Ron
RobMcAveney - Thursday, April 26, 2007 5:19 PM:
You can just disable the item_number field, like this:
<script>
function getNumber() {
var newNum="";
newNum=top.aras.getNextSequence('',"Re_Reports");
newNum = newNum + document.forms[0].name.value;
handleItemChange("item_number", newNum);
document.getElementById("seqButton").style.display="none";
document.getElementById("item_number").disabled="1";
}
</script>
<a id="seqButton" href="BLOCKED SCRIPTgetNumber();"><img src="../images/icons/16x16/16x16_sequences.gif" border="0" ></a>
Rob
Ron - Friday, April 27, 2007 9:56 AM:
That worked great, now building on this theme. I will be using one sequence numbering system for different types of documents. I have identified the different types using classification, and for some types I will need to add a prefix to the sequenced number. Since I will be using the same sequence number I can not at the prefix directly to the sequence, therefore I was thinking based on this code that it would be possible to simply filter on Classification and add the prefix to the generated number. now my javascript is not good but taking a stab at it this is what i was thinking;
<script>
function getNumber() {
var newNum="";
if (document.getElementById("classification").value="Markers") {newNum="MK" + top.aras.getNextSequence('',"MES_Doc_Num")}
else {newNum=top.aras.getNextSequence('',"MES_Doc_Num")};
handleItemChange("item_number", newNum);
document.getElementById("seqButton").style.display="none";
document.getElementById("item_number").disabled="1";
}
</script>
<a id="seqButton" href="BLOCKED SCRIPTgetNumber();"><img src="../images/icons/16x16/16x16_sequences.gif" border="0" ></a>
but this is not quite working, it always places the MK prefix
Any ideas
Thanks
Ron
thomas.hedberg - Wednesday, June 25, 2008 3:05 PM:
Ron,
What I did was created a drop down box with all our customers which drive the prefix for our parts and docs. I also add this field to the Part & Document ItemTypes so that we can search by the customer field as well. I have included my script below for our Document form.
<script>
function getNumber() {
var newNum="";
var strCustPart="Default Part"
strCustPart=document.forms[0].customer_doc.value;
newNum=top.aras.getNextSequence('',strCustPart);
newNum = newNum;
handleItemChange("item_number", newNum);
// document.getElementById("seqButton").style.display="none";
}
</script>
<a id="seqButton" href="javascript':getNumber();"><img src="../images/icons/16x16/16x16_sequences.gif" border="0" ></a>
As you can see, I created a strCustPart variable which stores the value of the drop down box, that value then gets passed to the getNextSequence function. The end result is a Part or Document number related to our Customer.
I know this is not exactly what you are trying to do, but I hope that gives you some insight.
Good Luck,
Tom Hedberg, Jr.
Advatech Pacific, Inc.