Skip to main content
7-Bedrock
April 19, 2023
Question

Work Package customization

  • April 19, 2023
  • 1 reply
  • 627 views
I am using Windchill PDMLink Release 11.0 and Datecode with CPS M030-CPS14

Having an issue creating a custom recipe for a work package via api calls. The setRecipe api I'm attempting to use returns a null value. Is there another way to create a custom recipe by way of a customization? If not, can anyone assist in why the setRecipe api is not working? Below is a snippet of the code I'm using to try and set it. I had a logger with a getRecipe call and it returned null.

PersistedCollectionRecipe recipe = PersistedCollectionRecipe.newPersistedCollectionRecipe();


// Set collector options on the recipe
String COLLECTION_OPTIONS = "" + "CADDOC_DEPENDENTS:None," + "ASSOCIATED_WTPART:None," + "DRAWINGS:None,"
+ "FAMILY:None," + "GENERICS:None," + "ASSOCIATED_EPMDOC:None," + "ASSOCIATED_WTDOCS:None,"
+ "RELATED_NOTES:None," + "CHANGE_ACTIVITY_RESULTING_DATA:None," + "CHANGE_OBJECTS_AFFECTED_DATA:None," + "PUBLISHED_CONTENT:All," + "PROBLEM_REPORT:None,"
+ "VARIANCE:None," + "CHANGE_REQUEST:None";

recipe.setCollectorOptions(COLLECTION_OPTIONS);

    1 reply

    6-Contributor
    March 5, 2026

    Hi TWil24,

    just saw this question when searching for PersistedCollectionRecipe at PTC.

    We have some code like this that works in WT 12.1.2 and I think also earlier.

    Code was developed before I joined the project, but it works.

     

     

    PersistedCollectionHelper.service.addSeeds(workPackage, members);

    logger.debug(logPrefix + "Added seeds to workpackage:" + members);

     

    PersistedCollectionRecipe pkgRecipe = PersistedCollectionRecipe.newPersistedCollectionRecipe();

    pkgRecipe.setCollectorOptions(COLLECTION_OPTIONS);

    logger.debug(logPrefix + "created pkgRecipe=" + pkgRecipe);

     

    pkgRecipe.setExpansionCriteria(some constructed NavigationCriteria);

    PersistedCollectionHelper.service.setRecipe(workPackage, pkgRecipe);

     

    PersistedCollectionRefreshInfo info = new PersistedCollectionRefreshInfo(workPackage,

    WPHelper.service.getCollectorId(workPackage), Locale.ENGLISH);

    info.enableSoftFiltering(true);

     

    PersistedCollectionRefreshInfo refreshInfo = PersistedCollectionHelper.service.refreshMembers(info);

    if (refreshInfo != null) {

    workPackage = (AbstractWorkPackage) refreshInfo.getHolder();

    }

     

    // Apply the filter so that the filter is refreshed.

    workPackage = (AbstractWorkPackage) PersistedCollectionHelper.service.applyFilters(workPackage);