• Claire Crabtree
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
I am using the following script to check which profiles have Edit Permissions for specific fields. For some reason, it is only returning a few profiles, where I was expecting all of them. Will there only be a FieldPermissions record if the profile does not have "No Access" to the object?
String obname = 'Account';
String myfieldname = 'Name';
Boolean isField = false;
Integer falsecount = 0;

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get(obname).getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values()){
    schema.DescribeFieldResult dfield = sfield.getDescribe();
    if(String.valueOf(dfield.getname()).containsIgnoreCase(myfieldname)){
        System.debug(myfieldname + ' is a field on ' + obname);
        isField = true;
    }
}

IF(isField == true){
    String myquery = 'select field, PermissionsEdit, PermissionsRead, parentid, parent.isownedbyprofile, parent.profileid, parent.profile.name from fieldpermissions where sobjecttype = \'' + obname + '\' AND field = \'' + obname + '.' + myfieldname + '\' AND parent.profileid != \'\'';                                       
    List<FieldPermissions> objectField = Database.query(myquery); 
    System.debug('size of list: ' + objectField.size());
    for(FieldPermissions fp : objectField){
        System.debug(fp.parent.profile.name + ' profile, edit: ' + fp.permissionsedit);
        if(fp.permissionsedit == false){
            System.debug(fp.parent.profile.name + ' profile, edit: ' + fp.permissionsedit);     
        falsecount += 1;
        }
    }
    if(falsecount == 0){
        System.debug('There are no profiles that do not have edit access to the field ' + myfieldname );
    }
}
else{
    System.debug(myfieldname  + ' is not a field on ' + obname);
}

 
Hello, I am an admin adventuring into learning code and I cannot figure out why the following Lightning Web Component is not working. (I've left out some of the code for simplicity.) Thank you!

HTML:
<p>Total Licenses:<span class="slds-p-horizontal_small">{totalPartnerLicenses}</span></p>

JS:
import { LightningElement, track, wire } from 'lwc';
import queryTotalPartnerLicenses from '@salesforce/apex/queryForLicenses.queryTotalPartnerLicenses';
export default class PartnerCommunityLicenses extends LightningElement {
@track totalPartnerLicenses = 7;
@wire(queryTotalPartnerLicenses) totalPartnerLicenses;
}

APEX CLASS:
public with sharing class queryForLicenses {
@AuraEnabled(cacheable=true)
public static Integer queryTotalPartnerLicenses(){
List<UserLicense> totalPL = [SELECT ID, TotalLicenses FROM UserLicense WHERE Name = 'Partner Community'];
UserLicense pl = new UserLicense();
Integer numTotalLicenses;

if(totalPl.size()>0){
pl = totalPL[0];
numTotalLicenses = Integer.valueOf(pl.TotalLicenses);
}
else {
numTotalLicenses=0;
}
return numTotalLicenses;
}
}
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_edit_record

SECTION:
Edit a Record with a Custom Layout Using lightning-record-edit-form

Is it missing a </lightning-record-edit-form>?
Also, should the second div class be 2-of-2?

Thanks for helping a budding developer.
Hello Guys, I'm new to Apex Triggers. I need help in writing a test class for the below Trigger. Whenever a platform event message (unique Id) is published from a lightning flow, the trigger updates the Service Appoinmtment record whose Id is the event message. Please let me know if I should make any changes to the trigger. 
trigger platformtrigger on Notification__e (after insert) {
    for(notification__e ev: Trigger.new)
        
    {
        
        ServiceAppointment SADispatched = [SELECT Id, ParentRecordId FROM ServiceAppointment WHERE Id = :ev.message__c];
        SADispatched.description = 'Automate Process';
        SADispatched.FSL__Auto_Schedule__c = true;
        
        update SADispatched;    

        
    }
}