{"id":1562,"date":"2017-12-04T12:13:58","date_gmt":"2017-12-04T12:13:58","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1562"},"modified":"2020-01-09T09:39:11","modified_gmt":"2020-01-09T09:39:11","slug":"customize-changelist-description-field-with-templates","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/customize-changelist-description-field-with-templates\/","title":{"rendered":"Customize changelist description field with templates"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Customize changelist description field with templates<\/strong><br \/>\nThe way most of our customers add additional fields to the change description is with the use of triggers and scripts that add extra fields within the &#8220;description&#8221; field.<br \/>\nwww.perforce.com\/perforce\/doc.current\/ma&#8230;cmdref\/triggers.html<br \/>\nAs an example:<br \/>\nadd-fields.py:<\/p>\n<p>*********************<\/p>\n<p>#!\/usr\/bin\/python<\/p>\n<p>import os<br \/>\nimport sys<br \/>\nimport re<br \/>\nimport random<\/p>\n<p>users = [ &#8220;cpflaum&#8221;,&#8221;cpflaum2&#8243; ]<br \/>\nuser = sys.argv[2]<br \/>\nuser = user.lower()<\/p>\n<p>if user in users:<br \/>\ntempfile = str(random.random())<br \/>\ninput = open(sys.argv[1], &#8220;r&#8221;)<br \/>\noutput = open(tempfile, &#8220;w&#8221;)<\/p>\n<p>for line in input.readlines():<br \/>\nif re.search(&#8220;<enter description here>&#8220;, line):<br \/>\noutput.write(line)<br \/>\noutput.write(&#8220;\\n\\tMy Additonal field 1=<please provide description>\\n&#8221;)<br \/>\noutput.write(&#8220;\\n\\tMy Additonal field 2=<please provide description>\\n&#8221;)<br \/>\nelse:<br \/>\noutput.write(line)<\/p>\n<p>input.close()<br \/>\noutput.close()<\/p>\n<p>os.remove(sys.argv[1])<br \/>\nos.rename(tempfile, sys.argv[1])<\/p>\n<p>********************<br \/>\nBy &#8211; Chuck Pflaum <<a href=\"mailto:support@perforce.com\">support@perforce.com<\/a>><br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @<a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\"> twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Customize changelist description field with templates The way most of our customers add additional fields to the change description is with the use of triggers and scripts that add extra fields within the &#8220;description&#8221; field. www.perforce.com\/perforce\/doc.current\/ma&#8230;cmdref\/triggers.html As an example: add-fields.py: ********************* #!\/usr\/bin\/python import os import sys import re import random users&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[370],"tags":[315],"class_list":["post-1562","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-templates"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1562"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1562\/revisions"}],"predecessor-version":[{"id":1563,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1562\/revisions\/1563"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}