Get selected projects
Some tooltip text!
• 1 minute to read
• 1 minute to read
Tip
You can only retrieve projects for persons that are SuperOffice users (associates).
The signed-in user must also have permission to view those projects. Otherwise, an exception is thrown.
To view basic info, use NSProject:
NSProjectAgent projectAgent;
NSProject p = projectAgent.GetProject(1);
printLine(p.GetType());
To view (and possibly update) complex info, use NSProjectEntity:
NSProjectAgent projectAgent;
NSProjectEntity p = projectAgent.GetProjectEntity(1);
printLine(p.GetProjectType().GetValue());
NSProject[] GetProjectList(Integer[] p0)
To call GetProjectList()
, we need to create the list of project IDs first.
In this example, we use SearchEngine to get the ID of all projects headed by a specific associate and not marked as done.
String associateId = "5";
Integer[] projectIds;
SearchEngine se;
se.addFields("project","project_id");
se.addCriteria("project.associate_id", "OperatorEquals", associateId,"OperatorAnd", 1);
se.addCriteria("project.done", "OperatorEquals", "=","OperatorAnd", 1);
se.execute();
while (!se.eof()) {
projectIds.pushBack(se.getField(0).toInteger());
se.next();
}
NSProjectAgent agent;
NSProject[] projectList = agent.GetProjectList(projectIds);
NSProject[] GetProjectsFromContact(Integer contactId)
A company is implicitly linked to a project when at least 1 person in that organization is a member of that project.
Integer contactId = 4;
NSProjectAgent agent;
NSProject[] projectList = agent.GetProjectsFromContact(contactId);
foreach (NSProject p in projectList) {
printLine(p.GetProjectId().toString() +" | " + p.GetName());
}
NSProject[] GetProjectsFromPerson(Integer personId)
Integer personId = 5;
NSProjectAgent agent;
NSProject[] projectList = agent.GetProjectsFromPerson(personId);