Perforce Public Knowledge Base - Personalized Default Changelist Descriptions
Downloads Blog Company Integrations Careers Contact Try Free
Menu Search
Reset Search



Personalized Default Changelist Descriptions

« Go Back



How do I replace the default changelist description text, "<enter description here>," with custom default text, but still have Perforce force users to change this from the custom default value?


By default if a user does not alter the default change description, "<enter description here>", Perforce raises an error when saving the changelist form. This behavior can be retained, with custom default text.   A form-out trigger will allow you to adjust a form before it's presented to the user, and a form-in trigger can check to make sure that the form contains the information you require, including a change to the default text.

A form-out trigger fires just before the form is presented to the user, allowing your chosen application to adjust the text being displayed.   A form-in trigger fires when the form is returned to the Perforce Server, allowing your chosen application to check for certain values.  If a trigger script returns a non-zero value, the trigger is deemed to have failed, and the action will not complete. If a zero-value, the trigger passes and the action completes.

Here is an example with a trigger table that contains two entries - one "form-out" and one "form-in" trigger:

 desc-out form-out change "C:\trig\submitdesc.bat out %formfile%"
 desc-in form-in change "C:\trig\submitdesc.bat in %formfile%"

The file "submitdesc.bat" handles both form input and output based on the first parameter passed to the script.

Note: This script is neither fully tested nor supported; it is an example to demonstrate this technique. While you can use this script for your own purposes, it should be tested fully in a non-production environment and modified as needed:

@echo off

set opt=end
if ##%1##==##out## set opt=out
if ##%1##==##in## set opt=in
if ##%2##==#### set opt=end
set mydesc=[Task: description]
goto %opt%

sed "s//%mydesc%/" %2 > C:\tmpfile
mv C:\tmpfile %2
goto end

findstr /C:"%mydesc%" %2
if %errorlevel%==1 exit /b 0
if %errorlevel%==0 exit /b 1
goto end

set mydesc=
set opt=
@echo on

With these two trigger entries in place, entering the command "p4 change" opens a new change with the custom description, "[Task: description]". When saved and the default editor is closed, a new pending change is created.

If the default change is not changed when closing the editor, the new pending change is not created, and an error is displayed:

p4 change
Error in change specification.
'desc-in' validation failed:      [Task: description]
Hit return to continue...

Hitting return re-opens this form. If the editor is closed again without changing this description, the "Specification not corrected -- giving up." error is displayed, just as with the default change description.

More information about scripting is provided in the Perforce System Administrator's Guide.

For further assistance, please contact Perforce Technical Support.

Related Links



Was this article helpful?



Please tell us how we can make this article more useful.

Characters Remaining: 255