Hi,
Can someone help me please?
I am trying to do a dialog with a textbox where I will type a text, and i would like to get that text and put in "setValue(text)" to set value of the attribute, I had found one script and I've used some parts but it appear error in line 65 "__toString(dlg.getDlgText("Text0"))". How can I get the text from the textbox and insert it in the var inside the "setValue()"?
// -------------------------------------------------------- // Script para mudar valores de Atributos não editáveis // modelos e objetos de um certo grupo // // -------------------------------------------------------- function main() { var sname = new __holder(""); userdlg(); var ogroups = undefined; var oattribute = undefined; var ocurrentmodel = undefined; var ocurrentobjdef = undefined; var omodels = undefined; var oobjects = undefined; var ogroup = null; var i = undefined; var j = undefined; var numberofobjects = 0; var atributo = 0; var atributo2 = 0; var g_nLoc = Context.getSelectedLanguage(); ogroups = ArisData.getActiveDatabase().GroupList(ArisData.getSelectedGroups()[0]); for ( i = 0 ; i < ogroups.length; i++ ){ ogroup = ogroups[i]; omodels = ogroup.ModelList(true); for ( j = 0 ; j < omodels.length; j++ ){ ocurrentmodel = omodels[j]; var creator = ocurrentmodel.Attribute(Constants.AT_CREATOR,g_nLoc); creator.setValue(sname); } omodels = null; oobjects = ogroup.ObjDefList(); for ( j = 0 ; j < oobjects.length; j++ ){ ocurrentobjdef = oobjects[j]; var creator = ocurrentobjdef.Attribute(Constants.AT_CREATOR,g_nLoc); creator.setValue(sname); } oobjects = null; } ogroups = null; } function userdlg() { var nuserdlg = 0; // Variable for the user dialog box //var sattrstr = __createArray(""); // List of strings of selectable attributes. var userdialog = Dialogs.createNewDialogTemplate(0, 0, 300, 200, "Troca de Valores"); userdialog.Text(20, 100, 460, 20, "Digite o novo valor para troca"); userdialog.TextBox(20, 130, 530, 20, "Text0", 0); userdialog.OKButton(); userdialog.CancelButton(); // userdialog.HelpButton("HID_c8746560_2f2f_11d9_017b_e10284184242_dlg_01.hlp"); var dlg = Dialogs.createUserDialog(userdialog); var sSection = "Process_Office/348b7ef0-944f-11e1-5844-00505637013f"; ReadSettingsDlgValue(dlg, sSection, "Text0", 1); nuserdlg = Dialogs.show(dlg); // Showing dialog and waiting for confirmation with OK if (nuserdlg != 0){ sname = __toString(dlg.getDlgText("Text0")); // Write dialog settings to config WriteSettingsDlgValue(dlg, sSection, "Text0"); } return (nuserdlg != 0) } main();
Regards,
Jack
Hello!
To read user's text fields from dialogs I use next code:
//Dialog template var oTmplMain = Dialogs.createNewDialogTemplate(0,0,"DialogName"); //Text field oTmplMain.TextBox(20,20,50,14, "txRelease"); //Create dialog's window by template var oDlgMain = Dialogs.createUserDialog(oTmplMain); //Set predefined value of the text field oDlgMain.setDlgText("txRelease", "46C"); //Show the window of dialog if(Dialogs.show(oDlgMain) != -1) return; //Get text value from the text field var sText = oDlgMain.getDlgText("txRelease"); //Set attr value oObjDef.Attribute(Constants.AT_NAME, -1).setValue(sText);
Hope, this helps.
Hi Jack,
What is the error you are getting at that line ?
Have you using the imported files for this script? If not it might be the cause of the error you are getting on particular line.
If so do this, in script editor open the script right click and select properties, click on Imported files and select convertertools.js file.
Hope it will resolve the said issue.
Regards,
Vinay
Hi Vinay and IIya, thanks for helping.
I 've tried to get the value of the textbox but when the report was succefully runned, I had checked the attribute if the value was what I had inserted, but the attribute has the value something like this: [obj Object].
Maybe it is not getting the value of the dialog box.
What can I do?
Regards,
Jack.