简体   繁体   English

删除arraykey中所有行的最佳方法是什么?

[英]What is best way to delete all rows within an arraykey?

I have an entity Contact which has an array entity Specialties.我有一个实体联系人,它有一个数组实体 Specialties。 Just a standard one to many relationship.只是标准的一对多关系。 One contact many specialties.一接触多专业。 (Specialties entity has few columns, might not be relevant). (专业实体的列很少,可能不相关)。 I have a screen to add list of Specialties to a contact on the PCF.我有一个屏幕可以将专业列表添加到 PCF 上的联系人。 I want to add a custom Remove All button on the Contact screen which will delete all values on the array against the specific contact.我想在联系人屏幕上添加一个自定义的全部删除按钮,该按钮将删除数组中针对特定联系人的所有值。 A contact can have large number of specialties (~10000) What is best way to delete all the elements in the array?一个联系人可以有大量的专业 (~10000) 删除数组中所有元素的最佳方法是什么?

Currently, I have the below function on the action property of the button and it is clocking and timing out.目前,我在按钮的 action 属性上有以下 function ,它正在计时和超时。

for(spec in contact.Specialties) 
{contact.removeFromSpecialties(spec) //OOTB remove from array method}

Any other better way to remove ~10000 records from the array entity?从数组实体中删除约 10000 条记录还有其他更好的方法吗?

From your question above, I assume that you will have a "Remove All" button in PCF screen with an action that deletes all the speciality records associated with that particular contact, but you will not delete partial records (like one or few records).根据您上面的问题,我假设您将在 PCF 屏幕中有一个“全部删除”按钮,其中包含删除与该特定联系人关联的所有专业记录的操作,但您不会删除部分记录(如一条或几条记录)。

Also I assume the entity type of "Speciality" entity is "Editable" or "Retireable".我还假设“专业”实体的实体类型是“可编辑”或“可退休”。

Keeping the above assumption in mind, you can create a new function and call that function from "Remove All" button action property.牢记上述假设,您可以创建一个新的 function 并从“全部删除”按钮操作属性中调用该 function。

Given below the code that will hard delete the entire records from database table just like you execute a delete query against a DB table,下面给出的代码将硬删除数据库表中的所有记录,就像您对数据库表执行删除查询一样,

function removeAllSpecialitiesForContact(contactFromPCF : Contact){
 
  var specialityQuery = Query.make(entity.Speciality).compare(Speciality#Contact, Equals, contactFromPCF.ID)      
  var deleteBuilder = new com.guidewire.pl.system.database.query.DeleteBuilder.DeleteBuilder(specialityQuery)
  deleteBuilder.execute() 
 
}

This new approach might not get timeout after PCF action as you faced already.正如您已经面临的那样,这种新方法在 PCF 操作后可能不会超时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM