- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 07:36 AM
Hi Community,
I have create a widget as shown in the image. I want to get data from those html fields and save into my table. But it's working fine on client script and having issue with server script. When I click on the submit button data is save with undefine values into the required table.
Another issue: When form is loaded the undefine values are automatically save into the table.
html code:
<div class="fields-container">
<label>Roll No:</label><br>
<input type="number" id="roll_no" name="rollNo" ng-mode=""><br>
<label >Student Name:</label><br>
<input type="text" id="student_name" name="Name" ng-model="c.name"><br>
<label>Father Name:</label><br>
<input type="text" id="father_name" name="FatherName" ng-model="c.fname"><br>
<label >Program:</label><br>
<input type="text" id="program" name="Program" ng-model="c.program">
<center>
<button ng-click="c.submit()">
Submit
</button>
</center>
</div>
client script code:
api.controller=function() {
/* widget controller */
var c = this;
c.submit=function()
{
c.data.Name=c.Name;
c.data.FatheName=c.fname;
c.data.Program=c.program;
c.server.update();
}
};
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var gr = new GlideRecord("u_student_portal_table");
gr.initialize();
gr.setValue('u_name', input.Name);
gr.setValue('u_father_name', input.FatherName);
gr.setValue('u_program', input.Program);
gr.insert();
})();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 07:43 AM - edited 04-14-2023 07:59 AM
Can you update server side script as follows and try again!
if(input){
var gr = new GlideRecord("u_student_portal_table");
gr.initialize();
gr.setValue('u_name', input.Name);
gr.setValue('u_father_name', input.FatherName);
gr.setValue('u_program', input.Program);
gr.insert();
}
I have noticed their is one more issue in client side:
c.submit=function()
{
c.data.Name=c.Name; // it should be c.name
c.data.FatheName=c.fname;
c.data.Program=c.program;
c.server.update();
}
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 07:43 AM - edited 04-14-2023 07:59 AM
Can you update server side script as follows and try again!
if(input){
var gr = new GlideRecord("u_student_portal_table");
gr.initialize();
gr.setValue('u_name', input.Name);
gr.setValue('u_father_name', input.FatherName);
gr.setValue('u_program', input.Program);
gr.insert();
}
I have noticed their is one more issue in client side:
c.submit=function()
{
c.data.Name=c.Name; // it should be c.name
c.data.FatheName=c.fname;
c.data.Program=c.program;
c.server.update();
}
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 08:02 AM
Thanks Man