Home › Forums › SPJS-Utility › Please help! Problem with Custom form's Init_fields_v2()
- This topic has 3 replies, 2 voices, and was last updated 7 years, 6 months ago by Alexander Bautz.
-
AuthorPosts
-
-
May 11, 2017 at 04:42 #16534
Hi Alex and all,
I’m new to SPJS and need to implement exact solution for my site to display another list columns.
I understand that I need 2 .js files;
PullInformationFromConnectedList.js
spjs-utility.jsHowever, I also need to modify the init_fields()_v2 function in order for the demo code to work with my custom form site.
Refer to https://spjsblog.com/2010/01/25/how-to-use-these-scripts-in-a-customized-form/Here is what I did
1)I have replaced this function in my spjs-utility.js.function init_fields_v2(){
var res = {};
$(“td.ms-formlabel”).each(function(){
var thisID = this.id;
res[thisID] = $(this).parents(‘tr:first’);
});
return res;
}2) I added custom Id to the ‘s formlabel which I only insert 1 place in my create new form.
<td width=”190px” valign=”top” class=”ms-formlabel” id=”StatusCustomID”>3) I added the following to the CEWP in custom form site:
fields = init_fields_v2();
var myCompanyField = $(fields[‘StatusCustomID’]);
alert(myTitleField.html());I follow the rest of steps as arrFinAndDispName function.
Results:
alert(myTitleField.html()) shows “undefined”
Nothing display on my new form.Did I do anything wrong?
Thank you so muchNanD
-
May 11, 2017 at 21:12 #16545
Hi,
I think you have mixed up the variables – you assign the value to “myCompanyField” but alerts “myTitleField”. Try alerting “” instead.If this don’t work, you can try using the developer console (hit F12 > Console) and type this in the console to see if the fields object contains your fields:
fields
Hit enter and look at the output.
Alexander
-
May 11, 2017 at 23:51 #16547
Thank you so much Alex.
I had fixed the code and the alert shows [object object]. Is it supposed to show this?
Besides this, are my above steps correct? especially editing init_fields_V2() in spjs-unitilty.js while leaving the init_fields() function in the file?
Thank you so much
-
May 24, 2017 at 20:08 #16674
Hi,
Sorry for the late reply. The alert [object object] means it is an object type an not a string. You can use console.log(PUT_VARIABLE_HERE) to see what the variable contains. Please note that you must have the developer console open (hit F12 > Console) to see the output.Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.