Below is an image of standard account history related list and another one that I am trying to replicate. I am not sure how to get the field label from Field from AccountHistory. Also, how to go about formatting the CreatedDate and AnnualRevenue in my data table.

Any help is appreciated.

Thank you

Related Lists

  • I was able to format the date by addiing following typeAttributes typeAttributes: { day: 'numeric', month: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit', hour12: true }
    – mSinisa
    Feb 4 at 22:27

Use getObjectInfo to get the field names and data types. You can't use lightning-datatable, though, because the types can vary in the old value/new value columns. Use lightning-formatted-date-time, etc based on the field type you get from getObjectInfo.

  • Do you have an examle of this by any chance? I am gettting the object info with a wired method but I am not sure how to assign a type dynamically since the data type for each row can be different.
    – mSinisa
    Feb 4 at 23:34
  • 1
    @ams You'd loop through each row of the result, check what the data type is, and assign a flag in each row. Then, you'd use if:true to render the appropriate component for each row. I have some stuff to do in a few minutes, but I can probably circle back around in the morning with at least a starter example.
    – sfdcfox
    Feb 4 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.