- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2019 11:39 PM
I have a scenario where my Table A has a reference field (lets say X) which is referring to Table B. The reference field (X) on Table A is being populated by BR on run-time. So if a matching value of it is found in Table B the same value should get populated in the field else the BR should create the value in table B and populate it in Table A field (X). I have used
Enable dynamic creation for reference fields
But seems it isn't working.
In Detail :
var MyUserReferenceCreator = Class.create();
MyUserReferenceCreator.prototype = {
initialize: function() {
},
create: function(current) {
gs.log("Inside MyUserReferenceCreator");
var month_name=new Array(12);
month_name[0]="January";
month_name[1]="February";
month_name[2]="March";
month_name[3]="April";
month_name[4]="May";
month_name[5]="June";
month_name[6]="July";
month_name[7]="August";
month_name[8]="September";
month_name[9]="October";
month_name[10]="November";
month_name[11]="December";
var gdt = new GlideDateTime();
var value = month_name[gdt.getMonthUTC()-1]+"-"+ gdt.getYearUTC();
gs.log("Inside MyUserReferenceCreator value : "+ value);
current.u_cross_charge_month_year = value;
return current.insert();
},
type: 'MyUserReferenceCreator'
};
Even the log statements aren't visible in the logs. which means the script isn't executing.
Any help is highly appreciated.
EDIT : This functionality works when I insert value in u_cross_charge_month_year from form view. But needs to achieve this from BR.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 05:29 AM
This issue is resolved. Had to go with the usual approach of creating a new field and assigning the sys_id in reference field using script include and business rule. Seems the dynamic creation of reference field usually works on front end only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 01:04 AM
Try adding javascript: before you call the script include. I've not configured this before but it looks the same as how you call an advanced reference qualifier.
javascript: new MyUserReferenceCreator().create(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 02:32 AM
Not working in this case 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 05:29 AM
This issue is resolved. Had to go with the usual approach of creating a new field and assigning the sys_id in reference field using script include and business rule. Seems the dynamic creation of reference field usually works on front end only.