• Nitin Ledange
  • NEWBIE
  • 35 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I all of a sudden started to get this Error. Related to Picklist. It was working fine yesterday.

User-added image
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 0060I00000UJtyaQAD; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3010I000000YTYA. Flow error messages: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.: []
Does Anybody know the solution? 
Hi Guys, I'm trying to display all the related contacts to all the related Accounts (Accounts are returned by a SOQL query when I input some name in VF Page nd it uses Like 'input%' ). But I'm getting Visualforce Error  System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!find}' in component <apex:commandButton> in page passingvaluestocontroller: Class.aaPage52.find: line 24, column 1 Class.aaPage52.find: line 24, column 1 . 

Here's My Code : 
VF PAge : 
<apex:page controller="aaPage52">
<apex:form >
<apex:pageBlock title="Search" >
<apex:outputLabel for="searchString" value="Enter the Search String : ">
</apex:outputLabel>
<apex:inputText value="{!searchText}" id="searchString"/>
<apex:commandButton value="Find" action="{!find}" />
</apex:pageBlock>
<apex:pageBlock title="Results">
<apex:pageblockTable value="{!results}" var="r">
<apex:column value="{!r.name}"/>
<apex:column value="{!r.Phone}"/>
<apex:column value="{!r.Industry}"/>
</apex:pageblockTable>
</apex:pageBlock> 
<apex:pageBlock title="Contacts Related to this Account">
<apex:pageblockTable value="{!Contacts}" var="con">
<apex:column value="{!con.FirstName}"/>
<apex:column value="{!con.LastName}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Controller : 

public class aaPage52 {
    List<Account> results;
    List<Contact> con;
    public String searchText { get; set; }    
    public List<Account> getResults() {
        return results;
    }    
    public List<Contact> getContacts() {
        return con;
    }
    
    public pageReference find(){
     results = [Select Name,Phone,Industry from Account where name LIKE :searchText+'%']; 
     If(results.size()!=0){
     List<contact> cont;
     for(Integer i=0; i< results.size(); i++){
       cont  = [Select FirstName, LastName from Contact where AccountID =:results[i].Id];       
     }
     con.addAll(cont);
     }
     update con;
     return null;
    }   
}

And Earlier when I didn't use con.addAll(cont); , I was able to Display the related Contacts  when Only one Account was returned by the Account Query. 


Appreciate your help.
Thanks,
Nitin Patil
We have Layout Read-only fields to be added. Seems like a bug, when we try to add read-only fields they become read-write on layout. Please see below example.
 
public class metadatatest {
    public static void runUpdateLayouts(){        
        Metadata.Layout la = getLayout('Account-Account Layout');

        Metadata.LayoutSection sec = new Metadata.LayoutSection();
        sec.customLabel = true;
        sec.detailHeading = true;
        sec.editHeading = true;
        sec.label = 'Custom fields';
        sec.style = metadata.LayoutSectionStyle.OneColumn;

        Metadata.LayoutColumn col1 = new Metadata.LayoutColumn();

        Metadata.LayoutItem layoutField = new Metadata.LayoutItem();

        layoutField.field = 'testfield__c';
        layoutField.behavior = metadata.UiBehavior.Readonly;

        col1.layoutItems.add(layoutField);
        sec.layoutColumns.add(col1);

        la.layoutSections.add(sec);

        Metadata.DeployContainer dc = new Metadata.DeployContainer();
        dc.addMetadata(la);

        Id jobid = Metadata.Operations.enqueueDeployment(dc,null);
    }

    public static Metadata.Layout getLayout(String layoutName){
        List<String> layoutList = new List<String>{layoutName};
            List<Metadata.Metadata> components = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, layoutList);
        return (Metadata.Layout)components[0];
    }
}


Above code will add testfield__c field to Account standard layout. But it shows as Readonly in Layout editor. But in Account both view and edit modes it's read-write.

On Layout editor:
In Layout editor

On View/Edit mode:
Edit/View Mode

It's actually editable and saving data to Account object here. Feel free to try out above code snippet. Appreciate any fix/workaround for this. Thanks.

 
Hello
I have some difficulty in understanding the following

a) Normally apex code & trigger run in system.context
   But How to make the apex code execute in USER Mode?
   if the apex code executing in USER Mode  is called by a trigger, will the trigger also execute in USER Mode?

b) Can a visual force page run in USER Mode instead of system.context , again what changes need to be done and why?

c) By default webservice classes written in apex , rest api execute in what Mode?

d) what is the use of system.RunAs with respect to the above.

I hope I am clear

Thanks
Vandana R