Search In This Blog

2022-11-30

Custom auto open utility bar without popout button by aura

cmp
<aura:compomemt implements="lightning:utilityItem">
    <!-- define popout to false -->
    <aura:attribute name="supportsPopOut" type="Boolean" default="false" />

    <!-- auto open utility bar when init -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <!-- use lightning:utilityBarAPI -->
    <lightning:utilityBarAPI aura:id="utilitybar" />

    someting else
</aura:compomemt>

controller.js
doInit: function(component) {
    var utilityApi = component.find("utilitybar");
    utilityApi.getAllUtilityInfo().then(fuction (response) {
        if (typeof response != "undefined") {
            utilityApi.openUtility();
        }
    });
}

Get recordId in LWC

Way 1
In js-meta.xml, set targets page
<isExposed>true<isExposed>
<targets>
    <target>lightning__RecordPage<target/>
</targets>

Then use @api to get recordId
import { LightningElement, api } from 'lwc';
export default class Sample extends LightningElement {
    @api recordId;
}

Way 2
Use CurrentPageReference
import { LightningElement, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
export default class Sample extends LightningElement {
    currentPageReference;

    @wire(CurrentPageReference)
    setCurrentPageReference(currentPageReference) {
        this.currentPageReference = currentPageReference;
        console.log('recordId: ' + this.currentPageReference.attributes.recordId);
    }
}

2022-11-29

Delete by record id use Schema SObjectType

public without sharing class CustomDeleteCmpController {

    @AuraEnabled(cacheable=true)

    public static String init(Id recordId) {

        // object name

        return recordId.getSobjectType().getDescribe().getLabel();

   }

 

    @AuraEnabled

    public static String doDelete(Id recordId) {

        try {

            String objApiName;

            RecordDelete.deleteLists(new List<SObject>{recordId.getSobjectType().newSObject(recordId)});

            if (String.isNotBlank(recordId)) {

                objApiName = String.valueOf(recordId.getSObjectType());

            }

            return objApiName;

        } catch (Exception ex) {

            throw ex;

        }

    }

}

Use 3rd Party Resource in LWC

import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
// static resource
import myResourceName from '@salesforce/resourceUrl/myResourceName';


initianlized = false;
Use in renderedCallback() {
    if (this.initianlized) {
        return;
    }
    this.initianlized = true;
    Promise.all([
        loadStyle(this, myResourceName + '/css/myResourceName.css'),
        loadScript(this, myResourceName + '/js/myResourceName.js'),
    ]).then(() => {
        // do some thing
    });
}
myResourceName zip
/js/myResourceName.js
/css/myResourceName.css

2022-11-01

ReGet data without reload page

Reget data and raletive list data, but not reload page or redirect url.


In AURA

$A.get('e.force:refreshView').fire();


In LWC

import { getRecordNotifyChange } from 'lightning/uiRecordApi';

getRecordNotifyChange([{recordId: this.recordId1},{recordId: this.recordId2}]);

or

setTimeout(() => {
    eval("$A.get('e.force:refreshView').fire();");
},1000)

オブジェクト項目レベルセキュリティの一括管理

ツールなど経由して作成した項目はよく項目レベルセキュリティー権限をセットしていないです。

個別で項目レベルセキュリティーを設定するのは時間かかります。

一括管理の方法

1権限セット

2プロファイル:設定>プロファイル>項目レベルセキュリティ