title: Programmatically Creating a CustomField
body: <p>I've been trying to figure out how to create a custom field in my Jira Plugin by using the Atlassian SDK, but I'm running into a couple of issues while wondering though the documentation and docs. Currently, I am able to create a custom field with the following code:</p>
  
  <pre><code>CustomField fieldType = customFieldManager.getCustomFieldObjectByName("Type of Work");
      CustomFieldSearcher fieldTypeSearcher = customFieldManager.getCustomFieldSearcher("com.atlassian.jira.plugin.system.customfieldtypes:select");
      if(fieldType == null) {
          List&lt;String&gt; issueTypes = new ArrayList&lt;String&gt;();
          issueTypes.add("Story");
  
          List&lt;String&gt; contextTypes = new ArrayList&lt;String&gt;();
          //contextTypes.add(GlobalIssueContext.GLOBAL_CONTEXT_STR);
          contextTypes.add("Global");
  
          /*Collection&lt;IssueType&gt; list = constantsManager.getAllIssueTypeObjects();
          for(IssueType issueType : list) {
              if(issueType.getName().equals("Story")) {
                  issueTypes.add(issueType);
              }
          }*/
  
          /*if(issueTypes.size() == 0)
              throw new Exception("Greenhopper must be installed!");*/
  
          CustomFieldType selectFieldType = customFieldManager.getCustomFieldType("com.atlassian.jira.plugin.system.customfieldtypes:select");
          try {
              CustomField typeOfWorkField = customFieldManager.createCustomField("Type of Work", "Used to track a stories type of work", selectFieldType, fieldTypeSearcher, contextTypes, issueTypes);
              //typeOfWorkField.
          } catch (GenericEntityException e) {
              writeMe += e.toString();
          }
      }
  </code></pre>
  
  <p>My issue lies in setting the customFields context and issueTypes. I want it to work in the global context and in greenhoppers Story Issue. Can anyone help out? Also, once I get that setup, I would like to set up the default screen. Any ideas?</p>