- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 09:59 AM
Hi all,
I'm new to scripting and trying to finish up this task I was assigned. I'm at a complete standstill. I need to create a list banner button UI Action on table A that calls a script include that creates a record on table B with some of it's fields populated. Can anyone help me out and point me in the right direction? Perhaps give some psuedo code. This assignment is really stressing me out.
thanks
Solved! Go to Solution.
- Labels:
-
Audit Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 10:35 AM
Hello Ryan,
There are multiple ways to do this, I am not sure if you need the Table B form opened after Button click.
OR
You need a pop up where you try to fill in values and then after submission you need a record in Table B.
I am writing a pseudocode where once you click the UI action on Table A record, The from reloads and you will be able to see Table B record. (No redirection this will show you your last session page)
------------------------
UI action:
Action name field should have : create_table_b_record
Client checkbox should be checked,
Onclick field should have this function name : createTableBRecord()
UI Action Script Section:
function createTableBRecord(){
gsftSubmit(null, g_form.getFormElement(), 'create_table_b_record'); --> action name
}
if(typeof window == 'undefined'){
new CreateTableRecordAction().tableBRecords(); --> Script Include Name and Function Name call.
//Use this line if you want to pass parameters>> new CreateTableRecordAction().tableBRecords(current);
}
--------------------
Script Include:
Name of Script Include : CreateTableRecordAction
Set client checkbox to true.
// Note that once you click on client checkbox the script will already have the below mentioned line of code with the SI name that you enter.
var CreateTableRecordAction = Class.create();
CreateTableRecordAction.prototype = Object.extendsObject(AbstractAjaxProcessor, {
tableBRecords :function() {
//Use this line if you have passed parameters from UI action >> tableBRecords :function(current) {
var gr = new GlideRecord('tableB');
gr.initialize();
// map all the required fields example gr.short_description = 'This is created from Table A';
gr.insert();
return true;
},
type: 'CreateTableRecordAction'
});
//*** You can also pass parameters of Table A from the UI action and send it to Script include to map on Table B., Refer the comments wherever necessary.
I hope this helps 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 10:35 AM
Hello Ryan,
There are multiple ways to do this, I am not sure if you need the Table B form opened after Button click.
OR
You need a pop up where you try to fill in values and then after submission you need a record in Table B.
I am writing a pseudocode where once you click the UI action on Table A record, The from reloads and you will be able to see Table B record. (No redirection this will show you your last session page)
------------------------
UI action:
Action name field should have : create_table_b_record
Client checkbox should be checked,
Onclick field should have this function name : createTableBRecord()
UI Action Script Section:
function createTableBRecord(){
gsftSubmit(null, g_form.getFormElement(), 'create_table_b_record'); --> action name
}
if(typeof window == 'undefined'){
new CreateTableRecordAction().tableBRecords(); --> Script Include Name and Function Name call.
//Use this line if you want to pass parameters>> new CreateTableRecordAction().tableBRecords(current);
}
--------------------
Script Include:
Name of Script Include : CreateTableRecordAction
Set client checkbox to true.
// Note that once you click on client checkbox the script will already have the below mentioned line of code with the SI name that you enter.
var CreateTableRecordAction = Class.create();
CreateTableRecordAction.prototype = Object.extendsObject(AbstractAjaxProcessor, {
tableBRecords :function() {
//Use this line if you have passed parameters from UI action >> tableBRecords :function(current) {
var gr = new GlideRecord('tableB');
gr.initialize();
// map all the required fields example gr.short_description = 'This is created from Table A';
gr.insert();
return true;
},
type: 'CreateTableRecordAction'
});
//*** You can also pass parameters of Table A from the UI action and send it to Script include to map on Table B., Refer the comments wherever necessary.
I hope this helps 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 11:03 AM
Thanks so much!!!!!!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2024 04:25 PM
Thank you.
Is this done on the list banner button? Would it recognise 'current