Embedded List Add or New Button

Radhika Aluru1
Mega Contributor

Hi All,

I have added an embedded list to a form. When user want to add any record in that related table, he needs to go through the Insert New Row and edit the entered record. In the normal related list, we can see New button. I searched in embedded list control and there is no option to set New or add button unlike in related list control.

I can see the Add button from the attachment of the below forum post.

Embedded Lists

Is there any setting that I need to modify to see the Add button in the embedded list?

Regards,
Radhika

1 ACCEPTED SOLUTION

Here is the UI macro code that we have created. I have used the sample code from SNC guru to open the popup and added little bit of code to pass the values to the dialog form



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
    <j:set var="jvar_n" value="add_${jvar_guid}:${ref}"/>
                <img border="0" src="add.gifx" title="${gs.getMessage('Add')}" alt="${gs.getMessage('Add')}" onclick="addEditUserPopopt('${ref}')"/>
          <script>
          //OnClick function for UI macro


          function addEditUserPopopt(reference){
               
                var v = gel('sys_uniqueValue').value;


if(v == ''){
                      var dialog = new GlideDialogForm('Add, your table name',saveOriginalForm);
                      dialog.setSysID('-1'); //Pass in -1 to create a new record
                }
               
                else{
         
               
                      var dialog = new GlideDialogForm('Add ', 'your table name',saveOriginalForm);
                      dialog.setSysID(-1); //Pass in reference sys_id to edit record
                }
                dialog.addParm('sysparm_view', 'default'); //Specify a form view
                dialog.addParm('sysparm_form_only', 'true'); //Remove related lists
             


                //Callback function executed from dialog submit
             
dialog.setLoadCallback(function(iframeDoc) {
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
var interval;
var count = 0;
interval = setInterval(function() {
try {
if (dialogFrame.g_form) {
dialogFrame.g_form.setValue('related field', v);
clearInterval(interval);
dialogFrame = null;
} else if (count > 50) {
clearInterval(interval);
dialogFrame = null;
}
}catch (e) {
clearInterval(interval);
dialogFrame = null;
}
count++;
}, 200);
});
dialog.render(); //Open the dialog
                }
function saveOriginalForm(action){
g_form.save();
}        
    </script>
</j:jelly>


View solution in original post

20 REPLIES 20

geoffcox
Giga Guru

I think if you want to add a row to an embedded related list, you just double click in one of the fields of the blank row at the bottom.


larmstrong
Tera Expert

I am in the exact same boat, however, I have added a button via UI Actions, but now I"m stuck with figuring out the scripting to add to the UI Action to make the button add a new record that will show up on my embedded list.



I plan to remove the "insert new row" option from the embedded list once I get the scripting to work.



Does anyone have any suggestions for the script?


Hi there,



I have added a UI macrowith a button element   below the embedded list. If user clicks on the button, it will open the dialog view of the form(that refers to the embedded list) to insert a record into the embedded list.



Regards,


Radhika


Hi Radhika,


Could you please explain how you have added in embedded list on the form?



I have a list on the form, but for normal user "Insert new row.." is not available. I want to provide an option to add new row using ui macro. I don't know how I can relate ui macro with that list.



Thanks in advance,


Mrinmoy