- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2020 04:31 AM
Hello everyone. I'll try to be as clear as possible but it's quite difficult to explain.
I have an applet 'Activity':
I have an action item and an action function :
And in my action function, participant number (one of my UI parameters) looks actually like this :
But, on the app, it generates a list of all the participant numbers who have records.
What I want is to autofill the participant number for the logged-in user or to have a list with only 1 participant number (the one of the logged-in user) when the participant creates a new steps record.
I also tried the autofill function with user, source field and append encoded query as input types but I always get the same message : 'Could not execute the action'.
Here are some more screenshots of the app itself and the applet in question. Hope you'll be able to help me 🙂
Thank you,
Roman
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2020 09:18 AM
Hi Roman,
Since you said the following;
What I want is to autofill the participant number for the logged-in user or to have a list with only 1 participant number (the one of the logged-in user) when the participant creates a new steps record.
I am assuming it would not be a bad thing if that option is not shown to the users but insteads just gets auto-populated with the participant number of the logged in user?
If that is the case, I would just suggest leaving out UI parameter for that participant number.
On the action item itself then, I would use a 'Script' type instead of a 'New' type and just script the creation of the record. Also make sure that the name of the item parameters for that action item do not include a space (Steps Records date -> steps_records_date)
The script would then look something like this:
(function WriteBackAction(input) {
// Initialize a new record
var stepsRecordsGR = new GlideRecord('x_aspas_steps_chal_steps_records');
stepsRecordsGR.initialize();
// write some code to retrieve the participant number of the logged in user
// The logged in user sys_id can be found with gs.getUserID()
// Save the number to a variable
var participantNumber = ....
stepsRecordsGR.setValue('participant_number', participantNumber);
// Set the other values by using the input object (which contains the action item
params)
stepsRecordsGR.setValue('description', input.steps_records_description);
...
// Insert the new record
stepsRecordsGR.insert();
})(input);
Kind regards,
Sébastien Van Someren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2020 09:18 AM
Hi Roman,
Since you said the following;
What I want is to autofill the participant number for the logged-in user or to have a list with only 1 participant number (the one of the logged-in user) when the participant creates a new steps record.
I am assuming it would not be a bad thing if that option is not shown to the users but insteads just gets auto-populated with the participant number of the logged in user?
If that is the case, I would just suggest leaving out UI parameter for that participant number.
On the action item itself then, I would use a 'Script' type instead of a 'New' type and just script the creation of the record. Also make sure that the name of the item parameters for that action item do not include a space (Steps Records date -> steps_records_date)
The script would then look something like this:
(function WriteBackAction(input) {
// Initialize a new record
var stepsRecordsGR = new GlideRecord('x_aspas_steps_chal_steps_records');
stepsRecordsGR.initialize();
// write some code to retrieve the participant number of the logged in user
// The logged in user sys_id can be found with gs.getUserID()
// Save the number to a variable
var participantNumber = ....
stepsRecordsGR.setValue('participant_number', participantNumber);
// Set the other values by using the input object (which contains the action item
params)
stepsRecordsGR.setValue('description', input.steps_records_description);
...
// Insert the new record
stepsRecordsGR.insert();
})(input);
Kind regards,
Sébastien Van Someren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2020 12:14 AM
Thanks a lot. I started from your code, modified it a bit and it worked ! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 08:58 AM
Hello Mathieu,
can you share your code please? I have the same problem as you, I tried the code shared by Sebastien, but it does not work for me !!
Best regards