PeopleTools | Automatically set the comment for all objects in a project.
A. ‘Don’t forget to comment’
Good programming practice suggests that you enter a comment for each PeopleTools object that you create as part of your project. In many cases however you might find yourself entering the same comment against every field, record, page and component. The standard comment usually includes similar types of information, such as developer’s name, date, and some form of project or change request number. If you have a large project, you might potentially have hundreds of new objects, so setting the comment manually is a tedious exercise. Fortunately, there is a quick way to initially set up a ‘template comment’ against each field, record, page, component and SQL object.
B. Setting Comments via Template Field
Start by manually entering the desired comment in any one of the new fields (we will call this the ‘template field’). Save the field. Then, run the following SQL statement. This will copy your original comment in the template field to every other field in the project. Make sure to replace TEMPLATE_FIELD_NAME and PROJECT_NAME with your specific details:
update psdbfield b set descrlong = (select descrlong from psdbfield b where b.fieldname = 'TEMPLATE_FIELD_NAME') where exists (select 'x' from psprojectitem a where a.objectvalue1 = b.fieldname and projectname = 'PROJECT_NAME' and objecttype = 2) and descrlong is null;
Note the final part of this statement (‘descrlong is null’). This ensures that you do not overwrite any existing comment entered for the field. In other words, the copy will only take place for fields that currently do not contain any comment.
Below are similar SQL update statements for records, pages, components and SQL definitions (in that order). Again, the template field described above is used as the source for the copy process.
update psrecdefn b set descrlong = (select descrlong from psdbfield b where b.fieldname = 'TEMPLATE_FIELD_NAME') where exists (select 'x' from psprojectitem a where a.objectvalue1 = b.recname and projectname = 'PROJECT_NAME' and objecttype = 0) and descrlong is null;
update pspnldefn b set descrlong = (select descrlong from psdbfield b where b.fieldname = 'TEMPLATE_FIELD_NAME') where exists (select 'x' from psprojectitem a where a.objectvalue1 = b.pnlname and projectname = 'PROJECT_NAME' and objecttype = 5) and descrlong is null;
update pspnlgrpdefn b set descrlong = (select descrlong from psdbfield b where b.fieldname = 'TEMPLATE_FIELD_NAME') where exists (select 'x' from psprojectitem a where a.objectvalue1 = b.pnlgrpname and projectname = 'PROJECT_NAME' and objecttype = 7) and descrlong is null;
update pssqldescr b set descrlong = (select descrlong from psdbfield b where b.fieldname = 'TEMPLATE_FIELD_NAME') where exists (select 'x' from psprojectitem a where a.objectvalue1 = b.sqlid and projectname = 'PROJECT_NAME' and objecttype = 30) and descrlong is null;
If you happen to have any project objects open while these SQLs are being run, the objects will need to be closed and re-opened in order to pick up the new comment.