2

I have a FlexCard. The datasource is the following

{ "user": 
  { "userId": "asd134224zdf"}
}

There is a custom LWC embedded inside. I am passing the following attribute attribute = userid | value = {user.userId}

My LWC essentially does the following (It does other things, but they are not relevant to my problem):

import { LightningElement, track, api } from 'lwc';
import { OmniscriptBaseMixin } from 'omnistudio/omniscriptBaseMixin'
export default class DeviceRosterLWC extends OmniscriptBaseMixin(LightningElement){
  @api userid;
  connectedCallback() {
    console.log('userId: ' + this.userid);
    console.log('userId stringify: ' + JSON.stringify(this.userid));
  }

}

Both console logs say

userId: undefined

userId stringify: undefined

I've tried passing the whole user node, but still it comes out undefined. Is there something I am missing?

1 Answer 1

1

If you have set the Result JSON Path as ["user"], you can directly access the userId as below.

Flex Card Setup

enter image description here

LWC JS

import { LightningElement,api } from 'lwc';
import { FlexCardMixin } from "omnistudio/flexCardMixin";
export default class FlexTestComponent extends FlexCardMixin(LightningElement){
    @api USERID;
}

LWC HTML

<template>
    USER ID - {USERID}
</template>

LWC Added to the Flex Card

enter image description here

LWC Output inside FlexCard

enter image description here

2
  • Hi Saroj, I've tried this and USERID still came out as undefined Also, if the LWC has USERID in all caps, then wouldn't we reference it in the FlexCard as u-s-e-r-i-d, as is LWC standard for attributes? I changed my class to extend "flexCardMixin" rather than "omniscriptBaseMixin", but that didn't help either. Commented May 16, 2023 at 13:09
  • 2
    FlexCardMixin tag I was searching for like hours, when I came across this post. Really helpful. Wondering why is this not part of documentation anywhere. Commented Jun 5, 2023 at 15:24

You must log in to answer this question.

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