• jmasl7x
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies
Anyone know why I have suddenly lost the ability to include a VF page in one of my sections on a custom object page layout?  It used to be there as recently as a few weeks ago and now I only see Scontrols, related lists, custom links, and fields for my object, no more "Pages".

Please advise...

Thanks
Is there any way for an S-Control to determine whether specific records of an object are read-only for the user before it attempts to update (or create) them?

The problem we have is that an S-Control allows a user to edit or insert records on an object ('Order Item') which is in a master-detail relationship with another object ('Order'). Depending on who the owner of the associated master record is, the user may or may not have the rights to perform these operations, although in the case of update the user does see the record to be updated, albeit as read-only.

I'd like the S-Control to detect this situation and notify the user rather than having the API call to create/update fail when the user attempts to save the changes.

Is this possible somehow?
I've created the following Apex Trigger and tested it in our sandbox environment. SFA_Order__c is a custom object we use to capture Orders and SFA_Delivery_Location__c is a non-mandatory field which is defined as lookup(Account).

Code:
trigger SFA_AU_setDeliveryAddress on SFA_Order__c (before update, before insert) {

    SFA_Order__c[] ords = Trigger.New;
    for (SFA_Order__c ord: ords) {
        String rt = ord.RecordTypeId;
        RecordType[] rts = [select Name from RecordType where id = :rt];
        if (rts.size() > 0 && rts[0].Name.startsWith('SFA AU')) {
        
            String acid;
            if (ord.SFA_Delivery_Location__c != null) acid = ord.SFA_Delivery_Location__c;
            else acid = ord.SFA_Account__c;
            
            Account[] ac = [Select BillingStreet,BillingPostalCode,BillingCity
                            from Account where Id = :acid];
            if (ac.size() > 0) {
                ord.SFA_Account_Street__c = ac[0].BillingStreet;
                ord.SFA_Account_ZIP_Code__c = ac[0].BillingPostalCode;
                ord.SFA_Account_City__c = ac[0].BillingCity;       
            } 
        }
    }
}

 My question regards the retrieval of the Record Type name in order to make the comparison
rts[0].Name.startsWith('SFA AU')

It seems to me inefficient that the trigger should be querying the RecordType object (table?) every time it is executed. But is there a better way to do this? I thought perhaps I could specify

ord.RecordType.Name

in my comparison, but this gives me a error at runtime:

System.NullPointerException

Any help appreciated.

Regards

John
I've created the following Apex Trigger and tested it in our sandbox environment. SFA_Order__c is a custom object we use to capture Orders and SFA_Delivery_Location__c is a non-mandatory field which is defined as lookup(Account).

Code:
trigger SFA_AU_setDeliveryAddress on SFA_Order__c (before update, before insert) {

    SFA_Order__c[] ords = Trigger.New;
    for (SFA_Order__c ord: ords) {
        String rt = ord.RecordTypeId;
        RecordType[] rts = [select Name from RecordType where id = :rt];
        if (rts.size() > 0 && rts[0].Name.startsWith('SFA AU')) {
        
            String acid;
            if (ord.SFA_Delivery_Location__c != null) acid = ord.SFA_Delivery_Location__c;
            else acid = ord.SFA_Account__c;
            
            Account[] ac = [Select BillingStreet,BillingPostalCode,BillingCity
                            from Account where Id = :acid];
            if (ac.size() > 0) {
                ord.SFA_Account_Street__c = ac[0].BillingStreet;
                ord.SFA_Account_ZIP_Code__c = ac[0].BillingPostalCode;
                ord.SFA_Account_City__c = ac[0].BillingCity;       
            } 
        }
    }
}

 My question regards the retrieval of the Record Type name in order to make the comparison
rts[0].Name.startsWith('SFA AU')

It seems to me inefficient that the trigger should be querying the RecordType object (table?) every time it is executed. But is there a better way to do this? I thought perhaps I could specify

ord.RecordType.Name

in my comparison, but this gives me a error at runtime:

System.NullPointerException

Any help appreciated.

Regards

John
Anyone know why I have suddenly lost the ability to include a VF page in one of my sections on a custom object page layout?  It used to be there as recently as a few weeks ago and now I only see Scontrols, related lists, custom links, and fields for my object, no more "Pages".

Please advise...

Thanks