0

I'm trying to create an entity group through SuiteScript based upon creation of some custom records. However, I'm getting an error:

You cannot define this group type using this search.

The search being used is a search for contact records, the entity group is for contact records. If I create the entity group through the UI, it allows the search to be used in a group, but not through script.

var user = nlapiGetUser();
var entityGroupName = custRec.getFieldValue("name");
var gcSearch = nlapiCreateSearch("contact", filters, columns);
gcSearch.setIsPublic(true);
var searchID = gcSearch.saveSearch("Contact Search: " + enityGroupName, "customsearch_contact_srch_" + custRecID);

var egRec = nlapiCreateRecord("entitygroup", { grouptype : "Contact" , dynamic : "T" , recordmode : "dynamic" });
egRec.setFieldValue("groupname", "Contact Group: " + entityGroupName);
egRec.setFieldValue("groupowner", user);
egRec.setFieldValue("restrictedtoowner", "F");
egRec.setFieldValue("parentgrouptype", "CustJob");
egRec.setFieldValue("savedsearch", searchID);
nlapiSubmitRecord(egRec, true, false);

What am I missing? I did try initializing the type as "contact" instead of "Contact", but then I get an error saying the search ID value is invalid.

Michael McCauley
  • 853
  • 1
  • 12
  • 37
  • Could you compile a minimum-working example? Snippet or jsfiddle or something. – extempl Mar 18 '19 at 17:37
  • Set "entityGroupName" to whatever text string you want and set "filters" and "columns" to be empty arrays, and you have a minimum working example. – Michael McCauley Mar 22 '19 at 14:57
  • You have a typo here: `enityGroupName` (unlikely it will fix the issue though). Have you contacted their support anyway? It looks like it is not some syntax issue or something, this is a response from their api due to some logic they know for sure. – extempl Mar 22 '19 at 15:47
  • > `did try initializing the type as "contact" instead of "Contact", but then I get an error saying the search ID value is invalid.` Try to fix the typo above and use `contact` again – extempl Mar 22 '19 at 15:50

1 Answers1

0

The problem was the following line:

egRec.setFieldValue("parentgrouptype", "CustJob");

I removed it, and now it works perfectly.

Michael McCauley
  • 853
  • 1
  • 12
  • 37