Script to extract and assign values from a nested JS object - pdf

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.

Related

Script to access and assign values from a nested object

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.

Lotus Notes formula language : Compose document with default values

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.

How to set the default value and read the selected value of a Dropdown Listbox

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.

SharePoint 2010 SPD Workflow copy list item to new list and designate the content type

I have a functioning SPD workflow that copies the list item from list A to list B when the item in list A is marked approved.
My challenge is that list B has three content types to chose from. How do I designate which content type in list B to use when copying. I have a listbox that the user gets to choose what kind of a tool is being loaded. Some tools have required calibration dates and other tool specific items therefore the different content types.
I don't think you can specify the content type with Copy List Item - it should default to the default content type.
What I'd do instead is have my workflow Create List Item in List B, populating fields with values from Current Item. You can set Content Type ID by this process but it doesn't accept a variable, so use an If/Then block for each Tool type that only runs if that listbox value is selected.
Hope this helps!

Getting selected item from combobox itemrenderer and storing in object

I have a combo box itemrenderer in datagrid column. I want to get the user selected item from the dropdown of the row(s) (User may select values from combo box from multiple rows of datagrid) and corresponding values of all other columns of the rows and store it in an object . Then pass this object to database to update only those rows that user has changed.
I am able to get the selected item from combo box using "event.currentTarget.selectedItem" and corresponding values of all other columns of the rows using "valueSelect.ID", etc where valueSelect is object which contains data for datagrid. But am stuck with, how to store the selected item value of the combobox and corresponding values of all other columns of the rows into an Object?
I am seeking sample code to store selected item from combobox and its corresponding values of all other columns into an object which I can send to db.
If you're using Flex, you can bind the selectedItem property / object of the DataGrid to an Object (of the "type" used to render the ItemRenderer).
Or you can do it manually, store a reference to that object by declaring an Object (or some specific type) and then updating that value whenever a selection occurs.
So for example :
[Bindable]public var selectedItem:Object;
...
public function onComboBoxChanged(evt:ListEvent):void
{
selectedItem = dataGrid.selectedItem;
...
// comboBox specific logic here
...
}
That or, if you need something complex, possibly check out this post for a custom item renderer :
Flex DataGrid with ComboBox itemRenderer
Hope that helps!