I have a script (provided below) created to extract and assign values from a nested object to text fields residing on a PDF form. Unfortunately, the script fails resulting in a number of undefines due to what appears to be a Null f value. To clarify, the event.value is a value selected by the user that gets assigned to a combo box on the form. Hence, for whatever reason, the combo box selection is not getting assigned to variable 'f' in which event the script fails and results in undefines for the field values on the form. I am contemplating that the solution requires a minor script adjustment for accessing the objects values. Thank you ahead of time.
var oField = getField("dataSource");
oVendors = JSON.parse(oField.value);
for(j=0;j<14;j++){
f=getField("inf."+j);
f.value = oVendors[event.value][j];
}
Upon further reading and learning about how to create and use a JS
object, the initial script posted was entirely wrong. The script
required to extract and assign values from a JS object to text fields
residing on a PDF form is as follows:
dsFld =getField("dataSrc");// dataSrc is a hidden text field that
resides on the PDF form
oVendors = JSON.parse(dsFld.value);//parse oVendors, a JS object stored
as a JSON string in the hidden dataSrc field
btnDel=getField("btn.del");
var oFld;//declare var oFld for later use
var oPassData = oVendors[event.value];//assign a field value to var
oPassData
if(oPassData){
//walk members to fill form fields
for(var nNm in oPassData){ // skip fields that don't exist on form
oFld = this.getField("inf." + nNm);
if(oFld)
oFld.value = oPassData[nNm]// assign property values stored in
oVendors data object to associated PDF form fields
}
Sorry for my initial post and any inconvenience to the forum.
Related
I presently have a nested JS object of the format:
var oNames = {
Adobe:{LastUpdate:'03/09/2022',Website:'adobe.com',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'',SecondaryCC:'',PrimaryBank:'',SecondaryBank:'',SQ1:'First girlfriend',SA1:'Denise',SQ2:'Grade school attended',SA2:'OLPH',Notes1:'',Notes2:''},
Amazon:{LastUpdate:'10/06/2020',Website:'amazon.com',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'Discover',SecondaryCC:'Capital One',PrimaryBank:'',SecondaryBank:'',SQ1:'',SA1:'',SQ2:'',SA2:'',Notes1:'',Notes2:''},
AmericanGiant:{LastUpdate:'01/25/2022',Website:'american-giant.com',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'',SecondaryCC:'',PrimaryBank:'',SecondaryBank:'',SQ1:'',SA1:'',SQ2:'',SA2:'',Notes1:'Best Hoodies Made in the USA',Notes2:''},
Asus:{LastUpdate:'11/05/2022',Website:'https://www.asus.com/us/',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'',SecondaryCC:'',PrimaryBank:'',SecondaryBank:'',SQ1:'',SA1:'',SQ2:'',SA2:'',Notes1:'Goto for MB & Laptop Computers',Notes2:''},
.
.
.
]
Can someone please provide me with a sample script that loops through the object above to obtain the values for the properties in the object above associated with each name using the variable, cName, that derives its value from a selection made by an end user from a drop-down box form field that resides on a PDF form. In short, the value provided by the variable 'cName' will be one to match any one of the name values in the object, i.e., Adobe, Amazon, AmericanGiant, Asus in which event the remaining fields residing on the PDF form will be populated with those property values associated with the name selected. Hope this explanation is clear. Unfortunately, I am not as familiar working with object pairs as I am with arrays and as such am stuck creating a script that works with a nested object as provided above. Thank you ahead of time.
for(j=0;j<15;j++){
f=getField("inf."+j);
cName = oVendors[event.value][j];
}
"inf."+j denotes 1 of 15 PDF form fields to be populated from the values in the object associated
with the name in the object equal to 'cName', the name selected in the combo box that resides on the PDF form.
Upon further study of the JS object and its methods, the following script is
required to extract names stored inside a JS data object in a hidden text field
used to populate a drop-down box on the PDF form as follows:
dsFld =getField("dataSrc");// call getField method used to obtain the stored
data value in the hidden text field that resides on the PDF form
oVendors = JSON.parse(dsFld.value);// parse the JSON string to convert to a JS
object to complete tasks to follow
f = getField("cbNames");// call the getField method to get the
drop-down combo box field or later use
aNames=new Array();// create the temp array
for(var key in oVendors){// script to populate the temp array from names
taken from/stored in oVendors data object
aNames.push(key);
}
aNames.sort();// sort the names alphabetically in the temp array
f.setItems(aNames);// assign names from the array to the drop-down
Combo Box field on the PDF form
f.insertItemAt("Add or lookup and select a name");// Insert text item at
the topmost item provided in the drop-down combo box list
dsFld.value=JSON.stringify(oVendors);// convert JS obj back to a JSON
string value stored in the hidden text field
Sorry for the initial ambiguous post and any inconvenience to the forum.
What I need is ,
I have a button in a form where
with formula language (not in lotus script)
I compose a new form using #Command([Compose]; ""; "myForm");
but I need to pass some field value from current form .
The #SetField works for current form.
Is there any option ;
If I run Agent #command is possible to run with parameter in order to send current document ID and to create myForm , having values from current form ?
Thanks to advice me !
If document A with current form is selected, when you create document B with another form, then you simply enable the FORM- Property "Formulas Inherit Values from selected document" on the second tab of the properties.
In the field- formulas of form B just enter the name of the Field in Form A as Formula. e.G.: If the field in Form A is named "AEmail" then enter AEmail in the Value of field "BEmail" of Form B.
Beware: this "inheritance" is only done ONCE when the document is created, there will be no relation between the two documents to update BEmail, if AEmail changes. To update the values dependantly you would need to construct something like #GetDocField( unidOfDocA; "AEmail" ) but that would need some more knowledge of the formula language.
So I've added a field with the Dropdown type as Listbox via Screen Painter (SE51).
I've binded the data to the dropdown using the PBO and the VRM_SET_VALUES function.
I have 2 problems with this;
How do you set a selected value to the binded data?
How do you get the value selected by the user.
Data is bound to the dropdown using the following code;
LOOP AT it_zzdelay_text INTO wa_zzdelay_text.
wa_listbox-key = wa_zzdelay_text-zz_delay_reason.
wa_listbox-text = wa_zzdelay_text-zz_delay_reason_text.
APPEND wa_listbox TO it_listbox.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'ZZ_DELAY_REASON'
values = it_listbox.
The zz_delay_reason is the unique key and the zz_delay_reason_text is the accompanying text.
Update:
According to your code, the field on the screen should be: ZZ_DELAY_REASON
And you also need a global variant with the name.
Then you can Set/Get key value in PBO/PAI:
Set value:
ZZ_DELAY_REASON = 'KEY'.
Get Selected Value(key):
lv_key = ZZ_DELAY_REASON
======================================================
When select list is set by VRM_SET_VALUES, you may notice it is a "Key-Value" pair. The field "KEY" is filled into the screen field value when the user selects drop box.
I could provide detailed information if you attach your code in this question.
Firstly, several prerequisites are to be met to make a functional drop-down:
You item table should have type vrm_values
Values that are showed in the list should be in field text of the item line. Key should be in field key.
PARAMETER should have type LISTBOX.
After all that is done, answers for your questions would be:
Relation of KEY-VALUE is done via vrm_values type. Each line of this type is an drop-down item, where text is a visible text, and key is key.
Parameter automatically gets the key value after user selects the item in the listbox.
Here is the sample code:
REPORT drop-down.
TYPE-POOLS: vrm.
PARAMETERS p_werks LIKE t001w-werks VISIBLE LENGTH 20 AS LISTBOX OBLIGATORY.
DATA: t_werks TYPE vrm_values,
w_line LIKE LINE OF t_werks.
INITIALIZATION.
SELECT werks name1
FROM t001w INTO (w_line-key, w_line-text).
APPEND w_line TO t_werks.
ENDSELECT.
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_WERKS'
values = t_werks.
END-OF-SELECTION.
WRITE: / 'Selected factory:', p_werks.
I am writing an Xpage in which the user can create a new document. On field is a category field. I want this field to be a drop down or type ahead with the possible values to be based upon previous entries. The user should also be able to add a new entry.
So this is the equivalent to a traditional dialog list field with "formula for choices" and the formula comes form the first categorized field on a view, with the "Allow values not in list" checked.
I am using a dojo Combo Box, but it displays the values in the field itself, instead of in a drop down.
Not sure what I am doing wrong:
My code is
<xe:djComboBox id="djComboBox2"
style="width:400px">
<xe:this.value><![CDATA[${javascript:var tmpView:String = "tipsByCategory";
var tmpColumn = 1;
var tmpVals = #DbColumn("",tmpView,tmpColumn);
tmpVals}]]></xe:this.value>
</xe:djComboBox>
In djComboBox
property value does the data binding to a document's field or a
scope variable
property selectItems has to deliver the list of possible entries
user can choose from.
Your code should look like this then:
<xe:djComboBox
id="djComboBox2"
style="width:400px"
value="#{document1.yourField}">
<xp:selectItems>
<xe:this.value><![CDATA[${javascript:
var tmpView:String = "tipsByCategory";
var tmpColumn = 1;
var tmpVals = #DbColumn("",tmpView,tmpColumn);
tmpVals}]]></xe:this.value>
</xp:selectItems>
</xe:djComboBox>
i have a textbox and it will basically just be filled with figures, how can i set it to show after it was typed in the form of ### ### [WITH THE SPACE BETWEEN THOUSANDS,ETC]
Sounds as if you're looking for the MaskedTextBox.
Set it's [Mask property][1] to ### ###.
#
Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in the Text property. Plus (+) and minus (-) signs are allowed.
Try the Below coding it will solve your problem
If you give a value as 9786952
Then it display that value as 9 786 952
I have wrote this in Button_click Event
Me.TextBox1.Text = String.Format("{0:n0}", CDbl(Me.TextBox1.Text))
Me.TextBox1.Text = Me.TextBox1.Text.Replace(",", " ")
-Pandian
If you are using data binding you can define a format.
Create a model for your data, i.e. a class with properties for the data of each textbox, checkbox etc., with the correct data type. Your number property must be typed as a number (int or decimal etc.).
Create an object data source in the "Data Sources" task pane.
Drag and drop your number field from the data source to the form. This creates a textbox.
A BindingSource and a BindingNavigator component are added automatically to the form. If you don't need navigation, you can delete the BindingNavigator component, but keep the BindingSource.
Select the number textbox you just added. In the properties window open "(DataBindings)" and click on the three dots (...) next to "(Advanced)". Here you can select a format type from a list. If you select "Custom", a field "Custom format" appears where you can enter "000 000" or "### ###" as format.
Assign an instance of your model to the BindingSource.
MyModel _model = new MyModel { Number = 123456 };
MyBindingSource.DataSource = _model;
The binding mechanism automatically converts any number from the model to a formatted text in the textbox and converts text entered in the textbox back to a number in the model. Very practical.