Hi everyone,
I'm totally new to this, and am in way over my head. No programming experience, and the XML Source section is a mind blown area, but I am trying to update a dynamic form that has an "add subform" button, that has multiple scripts written in it. From what I can tell, it is using javascript or tooltip (told ya, definitely newer than a newbie). The form was originally created by someone else, I worked backwards to quasi-reverse engineer it, and am very close to having the final updated product.
The problem is when the user clicks the add subform button, the functionality does not work as it should. the pop-up box displays "add a blank section", "Copy this section", a solid black line, then "Delete this section"
If the user clicks "Copy this section" another pop up box will appear, that says, "How many instances of this section would you like to insert?". This is where it is broken. no matter the number the user inputs in this field, only one section is added. Also, the text that should be copied is not being copied either, so it is essentially just adding another blank section.
The delete section and add a blank section both work fine, it is the "Copy Section" that needs to be updated. The problem I am having is, I cannot find where to update this button! I have gone through all the actions in the action builder, and that isn't it. I cannot seem to find where I can edit the "instance manager"
Can anyone help me out on this?
Solved! Go to Solution.
The code you have refers to fields like AssetClass as a child of Row1, but this doesn't seem to be the case looking at the form hierarchy, which has field like AssetId, StockNbr.
Also the code is assuming the whole table DISP is repeating, not the rows within it. But since you seem happy with the "Add a blank section" and "Delete this section" I'm guessing this is what you want.
I think the way you have you will end up with lots of Add buttons
Anyway, you could try this code which doesn't care what the fields of the table are called, it just copies the whole thing. It also copies the section were the particular add button was clicked ... not the first one.
var cChoice = app.popUpMenu("Add a blank section", "Copy this section", "-", "Delete this section");
if (cChoice == "Add a blank section")
{
DISP.instanceManager.addInstance(1)
}
else if (cChoice == "Delete this section")
{
_DISP.removeInstance(1)
}
else if (cChoice == "Copy this section")
{
var cResponse = app.response("How many instances of this section would you like to insert?", ["Copy current section", ])
if (cResponse == "")
{
app.alert("No copy of the current section was inserted due to a null response.");
}
else
{
var sourceXML = DISP.dataNode.saveXML();
var j = 0
while (j < cResponse)
{
Dispositions.dataNode.loadXML(sourceXML, false, false);
_DISP.addInstance(1)
j++;
}
}
}
Hope that what you were after.
Bruce
Hi, sounds like a complicated form to start with. Can you add the code from the add subform button into this thread, so we can see what's going on. When you say the pop-up box displays does it look something like this?
If you are able to share your form, it maybe quicker for us to have a look, can you upload it to a file sharing site (like google docs, dropbox, or whatever) and post a link in this thread.
Regards
Bruce
Views
Replies
Total Likes
Hey Brian! Thanks for helping.
I am not sure where to get the code for the button, but yes! That is exactly what the button looks like when you click it
Views
Replies
Total Likes
Hi,
Try selecting the button, then under the Window menu select Script Editor ... or Ctrl-Shift-F5, then select "click" in the Show: drop down
Hopefully there you will see the code there, it would also help if you could include a screen shot of the forms hierarchy ... if you are unable to share the form.
I can't share the whole form due to sensitivity, but I can share screenshots. Tomorrow I will include some screen shots of the button and I will do the instructions you provided above. Thanks again for all your help with this, you're awesome!!
Views
Replies
Total Likes
Hey Bruce, here is the script:
var cChoice = app.popUpMenu("Add a blank section", "Copy this section", "-", "Delete this section");
if(cChoice == "Add a blank section")
{
DISP.instanceManager.addInstance(1)
}
else
if(cChoice == "Delete this section")
{
_DISP.removeInstance(1)
}
else if(cChoice == "Copy this section")
{
var cResponse = app.response("How many instances of this section would you like to insert?",["Copy current section",])
if (cResponse == "")
{
app.alert("No copy of the current section was inserted due to a null response.");
}
else
{
var j=0
while(j<cResponse)
{
var act = _DISP.addInstance(1)
act.Row1.AssetClass.rawValue = xfa.resolveNode("name_KSSD.Dispositions.DISP.Row1.AssetClass").rawValue
act.Row1.LastInvDate.rawValue = xfa.resolveNode("name_KSSD.Dispositions.DISP.Row1.LastInvDate").rawValue
act.Row1.AssetDescription.rawValue = xfa.resolveNode("name_KSSD.Dispositions.DISP.Row1.AssetDescription").rawValue
act.Row1.AssetCategory.rawValue = xfa.resolveNode("name_KSSD.Dispositions.DISP.Row1.AssetCategory").rawValue
act.Row1.OwningUIC.rawValue = xfa.resolveNode("KSSD.Dispositions.DISP.Row1.OwningUIC").rawValue
act.Row1.CondOpStatus.rawValue = xfa.resolveNode("name_KSSD.Dispositions.DISP.Row1.CondOpStatus").rawValue
act.Row1.RespUIC.rawValue = xfa.resolveNode("KSSD.Dispositions.DISP.Row1.RespUIC").rawValue
act.Row2.AssetComments.rawValue = xfa.resolveNode("name_KSSD.Dispositions.DISP.Row2.AssetComments").rawValue
j++;
}
}
}
From what I can decipher above, it looks like the form is looking at the main form at the very top of the hierarchy, and the field names are incorrect, along with the name of the file. Below is a screenshot of the hierarchy, I did change the name of the file for security purposes, I don't think it is a big deal having the form in the public, but just CMA to be sure. Just know that "name" as it is written in the script is in place for the name of within the script, and "FORM" as it is written in the hierarchy is written in place for the name that is in the hierarchy
Thank you all again for all your help
Views
Replies
Total Likes
The code you have refers to fields like AssetClass as a child of Row1, but this doesn't seem to be the case looking at the form hierarchy, which has field like AssetId, StockNbr.
Also the code is assuming the whole table DISP is repeating, not the rows within it. But since you seem happy with the "Add a blank section" and "Delete this section" I'm guessing this is what you want.
I think the way you have you will end up with lots of Add buttons
Anyway, you could try this code which doesn't care what the fields of the table are called, it just copies the whole thing. It also copies the section were the particular add button was clicked ... not the first one.
var cChoice = app.popUpMenu("Add a blank section", "Copy this section", "-", "Delete this section");
if (cChoice == "Add a blank section")
{
DISP.instanceManager.addInstance(1)
}
else if (cChoice == "Delete this section")
{
_DISP.removeInstance(1)
}
else if (cChoice == "Copy this section")
{
var cResponse = app.response("How many instances of this section would you like to insert?", ["Copy current section", ])
if (cResponse == "")
{
app.alert("No copy of the current section was inserted due to a null response.");
}
else
{
var sourceXML = DISP.dataNode.saveXML();
var j = 0
while (j < cResponse)
{
Dispositions.dataNode.loadXML(sourceXML, false, false);
_DISP.addInstance(1)
j++;
}
}
}
Hope that what you were after.
Bruce
Hey Bruce! Thanks again for all your help.
When you say "enter the following code", where do I enter it? Into the little white screen area of the JavaScript line?
Also, I think the field names it is looking to copy, are incorrect. The fields used to be named Asset Class, etc, but were changed when I started modifying the form to fit the needs of this particular form.
I'm going to try your script first, but if I go back and update the script to the correct field names, that may also fix the problem, no?
Thanks again, if you were local, I'd buy you a beer or 3 for sure!
Views
Replies
Total Likes
your script worked!
If I needed to copy it other pages of the form, I would just need to update the "DISP" and the "Dispositions" to match the table name and page name, right?
for example:
var cChoice = app.popUpMenu("Add a blank section", "Copy this section", "-", "Delete this section");
if (cChoice == "Add a blank section")
{
ACT.instanceManager.addInstance(1)
}
else if (cChoice == "Delete this section")
{
_ACT.removeInstance(1)
}
else if (cChoice == "Copy this section")
{
var cResponse = app.response("How many instances of this section would you like to insert?", ["Copy current section", ])
if (cResponse == "")
{
app.alert("No copy of the current section was inserted due to a null response.");
}
else
{
var sourceXML = ACT.dataNode.saveXML();
var j = 0
while (j < cResponse)
{
AssetCreationTemplate.dataNode.loadXML(sourceXML, false, false);
_ACT.addInstance(1)
j++;
}
}
}
Views
Replies
Total Likes
Hi,
Glad to hear you got it working. If you want to reuse the code you will need to change the three references, the table (DISP), the tables instance manager (the one starting with the underscore, _DISP) and the parent of the table.
If you have many of these the code could be moved to a script and those three arguments passed in.
Also, the script editor can be resized, or even undocked and placed on another screen if you have a multi screen setup.
Regards
Bruce
Thanks Bruce!
I have no clue what or even how to write a script. haha. Whoever created this form a few years ago likely did, but that person is long gone.
As for the copying to other pages, I think I got it. For the DISP table, the parent would be the Dispositions page, so I think I can get it figured out now.
I can't say thanks enough for all your help. This website/forum is EXTREMELY useful, and members like you that help newbies that ask probably really dumb questions to the pros is awesome.
Thanks again,
~Josh
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies