entry().set("Attendees","Martin,Julia,Amanda,Frank");
entry().set("Attendees",null);entry().set("Attendees",[]);entry().set("Attendees","");None of these appear to clear the list of items. What other method can be called to clear the list of items prior to each new entry?
Any pointers for either of these would be great. I will continue to look for ways to write an array from another library and post as I uncover workable methods.
For now I'm just working on a script to populate the multi-select list. I've got this initial take at what the trigger needs to do to use the project name in the current entry, and select only the Individuals in the Teams library and add those people to the list of available Attendees.
I'm getting an error message that "Individual" is not defined but I thought I'm using the field name correctly. Is it because Individual is the link field?
var teams = libByName("Teams");
var e = entry();
if (e.field("Project Name") == null){
exit(); }
else{
var people = teams.find(entry().field("Individual")); //get names of individuals in Teams library
}
for (i = 0; i < people.length; i ++) //cycle thru entries to get all people
{
if(people[i].field("Project Name") == e.field("Project Name")) //select only individuals assigned to project of current record
{
e.set("Attendees", people.join()); //populate multi-select with the matching names
}
}
message(e)
Do the steps above appear logical? What an I missing?
Thanks,
e.set("Attendees", people.join()); //populate multi-select with the matching names
var e = entry();
var project = e.field("Project").length;
if (project > 0) {
var linkedEntry = e.field("Project")[0];
var projectTeam = linkedEntry.field("Involved People");
var forSet = "";
for (var act in projectTeam) {
if (forSet !="")
forSet += ", ";
forSet += projectTeam[act];
}
entryDefault().set("Distribution", forSet);
}
var e = entry();
var project = e.field("Project").length;
if (project > 0) {
var linkedEntry = e.field("Project")[0]; // Should be an Entry object
var projectTeam = linkedEntry.field("Involved People"); // field() on the Entry object should be valid, but is Involved People a String or or a Link? If a String, why? If it includes commas, you'll fail.
var forSet = "";
for (var act in projectTeam) { // Loop should work, though projectTeam.join, ", ") would do it faster
if (forSet !="")
forSet += ", ";
forSet += projectTeam[act]; //
}
entryDefault().set("Distribution", forSet);
}
var e = entry();
var project = e.field("Project").length;
if (project > 0) {
var linkedEntry = e.field("Project")[0];
var projectTeam = linkedEntry.field("Involved People");
var forSet = [];
for (var i in projectTeam){
var object = {};
object["name"] = projectTeam[i].field("Name");
forSet.push(object);
}
entryDefault().set("Distribution", forSet);
}
var e = entry();
var project = e.field("Project").length;
if (project > 0) {
var linkedEntry = e.field("Project")[0];
var involvedPeople = linkedEntry.field("Involved People");
var forSet = [];
var l = involvedPeople.length;
for (var i = 0; i < l; i++) {
var names = involvedPeople[i];
forSet.push(names.field("Name"));
}
entryDefault().set("Participants", forSet);
entryDefault().set("Distribution", forSet);
e.set("Participants", "");
}