cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with groovy script

former_member620692
Active Contributor
0 Kudos
 flexibleSearchService.search(/SELECT {pRef:PK} FROM {Product AS p}, {ProductReference AS pRef} WHERE {p:catalogVersion}=
 ({{
     SELECT {PK} FROM {catalogVersion} WHERE {catalog}=
     ({{
         SELECT {PK} FROM {catalog} WHERE {id}='electronicsProductCatalog'
     }}) AND {version}='Staged' 
 }}) AND ({p:PK}={pRef:source} OR {p:PK}={pRef:target})/).result.each {modelService.remove it}

On executing the groovy script given above, I am getting the following error :

 Script execution has failed [reason: java.lang.IllegalArgumentException: Parameter 'model' is null!]

Interestingly, it works for single or multiple product codes mentioned explicitly e.g. the following code executes successfully:

 flexibleSearchService.search(/SELECT {pRef:PK} FROM {Product AS p}, {ProductReference AS pRef} WHERE {p:catalogVersion}=
 ({{
     SELECT {PK} FROM {catalogVersion} WHERE {catalog}=
     ({{
         SELECT {PK} FROM {catalog} WHERE {id}='electronicsProductCatalog'
     }}) AND {version}='Staged' 
 }}) AND ({p:PK}={pRef:source} OR {p:PK}={pRef:target}) AND {p:code} IN('2053226','4786113')/).result.each {modelService.remove it}

Similarly, the following code too executes successfully:

 flexibleSearchService.search(/SELECT {pRef:PK} FROM {Product AS p}, {ProductReference AS pRef} WHERE {p:catalogVersion}=
 ({{
     SELECT {PK} FROM {catalogVersion} WHERE {catalog}=
     ({{
         SELECT {PK} FROM {catalog} WHERE {id}='electronicsProductCatalog'
     }}) AND {version}='Staged' 
 }}) AND ({p:PK}={pRef:source} OR {p:PK}={pRef:target}) AND {p:code}='4786113'/).result.each {modelService.remove it}

Accepted Solutions (0)

Answers (0)