1

Is there any way to do a nulls check before calling @wire adapter (without refactoring callee)?

We are seeing this odd exception bubble up from somewhere (even if we swallow errors). It appears seldom and I am having trouble replicating it.

Exception:

Could not find any match for params: objectApiName
java.lang.IllegalStateException: Could not find any match for params: objectApiName
    at core.connect.rest.UrlBuilder.build(UrlBuilder.java:85)
    at core.connect.resources.ConnectUri.applyCommunityContextAndBuild(ConnectUri.java:103)
    at core.connect.resources.ConnectUri.applyCommunityContextAndBuild(ConnectUri.java:62)
    at core.connect.resources.ConnectUri.applyCommunityContextAndBuild(ConnectUri.java:50)
    at sfdc.uisdk.connect.api.output.list.ListViewSummaryRepresentationBuilder.build(ListViewSummaryRepresentationBuilder.java:138)
    at sfdc.uisdk.connect.api.output.list.ListViewSummaryCollectionRepresentationBuilder.build(ListViewSummaryCollectionRepresentationBuilder.java:208)
    at sfdc.uisdk.connect.api.output.list.ListViewSummaryCollectionRepresentationBuilder.build(ListViewSummaryCollectionRepresentationBuilder.java:1)
    at core.connect.java.direct.JavaResourceWrapper.build(JavaResourceWrapper.java:625)
    at core.connect.java.direct.JavaResourceWrapper.get(JavaResourceWrapper.java:132)
    at sfdc.uisdk.connect.api.wrappers.impl.ListUiDirect.getListsByObjectName(ListUiDirect.java:70)
    at sfdc.uisdk.connect.api.wrappers.impl.ListUiDirect$$FastClassBySpringCGLIB$$f279bd57.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
    at sfdc.uisdk.connect.api.wrappers.impl.ListUiDirect$$EnhancerBySpringCGLIB$$2d367c16.getListsByObjectName(<generated>)
    at sfdc.uisdk.connect.api.wrappers.impl.ListUiDynamic.getListsByObjectName(ListUiDynamic.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206)
    at com.sun.proxy.$Proxy247.getListsByObjectName(Unknown Source)
    at sfdc.uisdk.connect.api.wrappers.ui.ListUiController$1.run(ListUiController.java:93)
    at sfdc.uisdk.connect.api.wrappers.ui.ListUiController$1.run(ListUiController.java:1)
    at core.connect.api.utils.ControllerUtils.runWithExceptionHandling(ControllerUtils.java:78)
    at sfdc.uisdk.connect.api.wrappers.ui.ListUiController.getListsByObjectName(ListUiController.java:88)

Code:

import { LightningElement, wire, track, api } from 'lwc'
import { getListUi } from 'lightning/uiListApi'

export default class WireListView extends LightningElement {
    @api objectApiName
    @api listViewApiName
    @wire(getListUi, {
            objectApiName: '$objectApiName',
            listViewApiName: '$listViewApiName',
            pageSize : 2000
        })
    listView({ error, data }) {
        if(data) {
            const listUpdate = new CustomEvent('listviewupdated', { detail: {mydata : data} })
            this.dispatchEvent(listUpdate)
        } else {
            // Choose if you wish to handle or ignore errors
        }
    }
}

I'm guessing the exception comes when null objectApiName is passed in. I can set defaults as blank text, but not sure if this gonna help at all.

My goal is to not execute wire adapter at all if objectApiName is empty.

The context is AppExchange package.

1 Answer 1

2

$objectApiName is a dynamic property on which wire is dependent. Wire is internally handling undefined and null checks for dynamic properties. The wire service is not even firing when the dynamic property is null/undefined.

You need to check what exactly is objectApiName when you are getting this error and this might have something to do with type of object it is (that object may not support listUi)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .