- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2022 10:57 AM
we have 5 records in table A based on these records we need to grab some details from this record and create another contract record (via schedule job ) can someone help me with the code
Table A record contains: Short description , user ID , Start date
We need to grab each record in Table A and Create a record by copying Short des to Short dec , User ID to User ID etc via schedule job and once the record is created in Table B we need to set the state in Table A record as Completed.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2022 11:15 AM
Hi, can you be more specific about your requirements IE why do you need to use a scheduled job, what type of record is table A - a task extension? Running any sort of conditional filter query using free text fields like short description is both inefficient and prone to user induced failure.
As far as code goes, you will learn more if you attempt this yourself and post your script for review\assistance as required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2022 11:15 AM
Hi, can you be more specific about your requirements IE why do you need to use a scheduled job, what type of record is table A - a task extension? Running any sort of conditional filter query using free text fields like short description is both inefficient and prone to user induced failure.
As far as code goes, you will learn more if you attempt this yourself and post your script for review\assistance as required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2022 12:11 PM
var grCIServer = new GlideRecord('u_loto');
grCIServer.addEncodedQuery('u_state=new');
grCIServer.query();
while (grCIServer.next()) {
var grc = new GlideRecord('u_contract');
grc.initialize();
grc.date = gs.nowDateTime();
grc.amount = grCIServer.amount;
grc.short_description = 'MOTO SERV' + grCIServer.u_service_name;
grc.insert();
grCIServer.u_state = 'completed';
grCIServer.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2022 12:31 PM
Assuming u_loto is an extension of the task table?
then the state field will be 'state' not 'u_state' and it's value numeric not 'text'
IE the default 'Closed Complete' state value for most task tables is 3
grCIServer.addEncodedQuery('state=1');
grCIServer.u_state = 3;
Otherwise, without specific details of your configuration, the forum can only guess at your configuration and any resulting issues.
What are the results of your debugging\diagnostics?
Is u_contract extended from an existing table?
if it is not an extension, short description is probably u_short_description
Similarly if the 'amount' field is a custom field in either table?
then perhaps it should be referenced as u_amount?