So I've set up my RecyclerView with API and it's populating the list on the adapter but every time I click on the list item it should open the new activity and pass position through an interface. The click gives me NullPointerException: public class ticketsListAdapter extends RecyclerView.Adapter&lt;ticketsListAdapter.ViewHolder&gt;{ onclicklistner listners; Context context;  public ticketsListAdapter(Context context, onclicklistner listners) {     this.context = context;     this.listners = listners; }  @NonNull @Override public ticketsListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {     View view = LayoutInflater.from(context).inflate(R.layout.list_support_tickets,parent, false);     return new ViewHolder(view, listners); }  @Override public void onBindViewHolder(@NonNull ticketsListAdapter.ViewHolder holder, int position) {     holder.item_name.setText(&quot;hello&quot;); }  @Override public int getItemCount() {     return 5; }   public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {      TextView item_name;     public ViewHolder(@NonNull View itemView, onclicklistner listner) {         super(itemView);         item_name = itemView.findViewById(R.id.tickets_name);         item_name.setOnClickListener(this::onClick);     }       @Override     public void onClick(View v) {         listners.onItemClick(getAdapterPosition(), item_name);     } }  public interface onclicklistner{     void onItemClick(int position, View v); }  } Log cat &amp; Debug output: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.kalyani.aura, PID: 21421 java.lang.NullPointerException: Attempt to invoke interface method 'void com.kalyani.aura.adapters.ticketsListAdapter$onclicklistner.onItemClick(int, android.view.View)' on a null object reference     at com.kalyani.aura.adapters.ticketsListAdapter$ViewHolder.onClick(ticketsListAdapter.java:60)     at com.kalyani.aura.adapters.-$$Lambda$hRD_GBr-hvL2HaQtFW31sqkj_0o.onClick(Unknown Source:2)     at android.view.View.performClick(View.java:7125)     at android.view.View.performClickInternal(View.java:7102)     at android.view.View.access$3500(View.java:801)     at android.view.View$PerformClick.run(View.java:27336)     at android.os.Handler.handleCallback(Handler.java:883)     at android.os.Handler.dispatchMessage(Handler.java:100)     at android.os.Looper.loop(Looper.java:214)     at android.app.ActivityThread.main(ActivityThread.java:7356)     at java.lang.reflect.Method.invoke(Native Method)     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)  Fragment Where Recycler view Implemented public class support_fragment extends Fragment {  FloatingActionButton create_support; ticketsListAdapter.onclicklistner listner; RecyclerView recyclerView; ticketsListAdapter ticketsListAdapter;   @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {     View view = inflater.inflate(R.layout.fragment_support, container, false);      create_support = view.findViewById(R.id.create_support);     recyclerView = view.findViewById(R.id.support_recycler);     recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));     recyclerView.setHasFixedSize(false);     ticketsListAdapter = new ticketsListAdapter(getContext(), listner);     recyclerView.setAdapter(ticketsListAdapter);      create_support.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {             Intent i = new Intent(getContext(), Support_main_activity.class);             startActivity(i);         }     });      listner = new ticketsListAdapter.onclicklistner() {         @Override         public void onItemClick(int position, View v) {             Toast.makeText(getContext(), &quot;Test&quot;, Toast.LENGTH_SHORT).show();         }     };      return view; }  }
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
8665
I am trying to copy records from one org to other via web services. I am calling a class which has logic written into a trigger. But @ future method is not taking sObject  list as a parameter. Can someone suggest me an alternative?  The Code:  public class webServicesTriggerClass   {     @future public static void webServicesMethod(list&lt;MyFriend__c&gt; mfList)     {         partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();       partnerSoapSforceCom.LoginResult lr = sp.login('hitesh.kumar.singh@accenture.com.varun','4Rajyavardhan');      soapSforceComSchemasClassNiralaapp.SessionHeader_element ses = new soapSforceComSchemasClassNiralaapp.SessionHeader_element();      ses.sessionId = lr.sessionId;       soapSforceComSchemasClassNiralaapp.MyFriendsDetailSoapApi vNapp=new soapSforceComSchemasClassNiralaapp.MyFriendsDetailSoapApi();      for(MyFriend__c mf:mfList)       {        string  s1= mf.myEmail__c;        string  s2=mf.friendName__c;         string  s3=mf.friendEmail__c;        string  s4=mf.aboutFriend__c;        integer i1=Integer.ValueOf(mf.age__c);        boolean result=vNapp.addFriendDetails(s1,s2,s3,s4,i1);        system.debug('################' +result);           }     }    }     Trigger-->  trigger webServicesTrigger on MyFriend__c (after insert)     {      webServicesTriggerClass.webServicesMethod(trigger.new);    }     Error--    Error: Compile Error: Unsupported parameter type LIST at line 3 column 30
73868
I need help. I am currently trying to test this code before uploading  public class CoreValuesExt { ApexPages.StandardController sc; public boolean readonly {get; set;} public Core_Values__c cv {get; set;} public integer countEdit = 1; public string buttonValue {get; set;} public integer recordScan;  public CoreValuesExt(ApexPages.StandardController sc) {     this.sc = sc;     cv = new Core_Values__c();     cv.Account__c = sc.getid();      readonly = true;     buttonValue = 'Edit';     recordScan = [SELECT COUNT() FROM Core_Values__c WHERE Account__c = :cv.Account__c];    if (recordScan != 0){    cv = [SELECT id, HSE__c, Professionalism_Integrity__c, Quality_Accuracy__c, Technology_Innovation__c, Timeliness__c, Value_for_money__c FROM Core_Values__c WHERE Account__c = :cv.Account__c];     }  }  public ApexPages.PageReference Save() {     return sc.Save(); }  public void ApplyAction() {     countEdit++;     Integer modolus = Math.mod(countEdit, 2);     String total = cv.HSE__c + cv.Professionalism_Integrity__c + cv.Quality_Accuracy__c + cv.Technology_Innovation__c + cv.Value_for_Money__c + cv.Timeliness__c;     if(modolus == 0)     {         readonly = false;         buttonValue = 'Save';     }     else     {         if(total != 'nullnullnullnullnullnull')            {         if (recordScan == 0){         insert cv;         readonly = true;         buttonValue = 'Edit';         }         else         {         update cv;         readonly = true;         buttonValue = 'Edit';         }         }     }    }   }  With this trigger.  trigger CoreValuesTrigger on Core_Values__c (before insert) {  Core_Values__c cvs = Trigger.new; CoreValuesExt.ApplyAction(cvs);  }   But when I try to save, I get a message saying:      Illegal assignment from List to   CoreValuesExt__Core_Values__c at line 3 column 1   "  How do I go through with this? I need help. Thanks
18236
Steps to Reproduce   Tap faster on the code. or Tap once on a huge code.   but happens only when  setupForGeneric() is called, might be a bug related to   private void setupForCode()   { String str = getIntent().getStringExtra("com.stackexchange.marvin:code_block"); PrettyWebView localPrettyWebView = (PrettyWebView)findViewById(R.id.code); localPrettyWebView.setPostBody("&lt;pre&gt;&lt;code&gt;" + TextUtils.htmlEncode(str) + "&lt;/pre&gt;&lt;/code&gt;", false); localPrettyWebView.setBackgroundColor("#eeeeee"); }  private void setupForGeneric() { String str = getIntent().getStringExtra("com.stackexchange.marvin:web_url"); PrettyWebView localPrettyWebView = (PrettyWebView)findViewById(R.id.code); localPrettyWebView.getSettings().setBuiltInZoomControls(true); localPrettyWebView.getSettings().setLoadWithOverviewMode(true); localPrettyWebView.getSettings().setUseWideViewPort(true); localPrettyWebView.loadUrl(str); localPrettyWebView.setBackgroundColor("#eeeeee"); }   Log  09-05 03:54:30.312: E/AndroidRuntime(26264): FATAL EXCEPTION: WebViewCoreThread  09-05 03:09:39.522: E/Crittercism(18318): java.lang.NullPointerException: [v0.1.22]  09-05 03:09:39.522: E/Crittercism(18318):   at android.content.ComponentName.&lt;init&gt;(ComponentName.java:75) 09-05 03:09:39.522: E/Crittercism(18318):   at android.content.Intent.&lt;init&gt;(Intent.java:3156) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.ViewPopupActivity.showCode(ViewPopupActivity.java:25) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.question.QuestionFragment$1.onCodeClicked(QuestionFragment.java:67) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.common.PrettyWebView$WebAppInterface.codeClicked(PrettyWebView.java:197) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.nativeTouchUp(Native Method) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.nativeTouchUp(Native Method) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.access$4000(WebViewCore.java:59) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1449) 09-05 03:09:39.522: E/Crittercism(18318):   at android.os.Handler.dispatchMessage(Handler.java:99) 09-05 03:09:39.522: E/Crittercism(18318):   at android.os.Looper.loop(Looper.java:137) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:790) 09-05 03:09:39.522: E/Crittercism(18318):   at java.lang.Thread.run(Thread.java:856)
103246
I can't seem to call the objects out on the database and onto a visualforce page using this set up:   public with sharing class HarborEventController {  private final Event__c event; public HarborEventController(ApexPages.StandardController controller) {     this.eventlist = (Event__c)controller.getRecord(); }   public Integer eventcount{get;set;} public HarborEventController (){    eventcount = [SELECT COUNT() FROM Event__c];     }   public list&lt;Event__c&gt; mainlist {get;set;}   public list&lt;Event__c&gt; displayevents(){     mainlist = new list&lt;Event__c&gt;();     String mainsoql = 'SELECT Id, Name__C, Message__c, Display_Date__c, FROM Event__c';      mainsoql += 'ORDER BY Display_date__c LIMIT :5';     mainlist = Database.query(mainsoql);     return mainlist; }   and the visualforce page :           &lt;apex:composition template="eh_base"&gt;           &lt;apex:define name="heros-content"&gt;             &lt;/apex:define&gt;       &lt;apex:define name="content"&gt;        &lt;section id="services-sec"&gt;          &lt;div class="container"&gt;             &lt;div class="row" style="padding-top: 60px;"&gt;       &lt;apex:outputPanel layout="block" rendered="{!AND(NOT(ISNULL(mainlist)),mainlist.size&gt;0)}"&gt;         &lt;apex:form id="blockofeventtorepeat"&gt;             &lt;apex:repeat value="{!mainlist}" var="evententry" id="repeat"&gt;                 &lt;div class="col-md-9"&gt;                    &lt;h3&gt;&lt;apex:outputLink styleClass="evententry-header block" value="{!$Page.eh_eventdetails}?id={!evententry.id}"&gt;{!evententry.Name__c}&lt;/apex:outputLink&gt;&lt;/h3&gt;                     &lt;apex:outputPanel &gt;                      &lt;p&gt;                          &lt;img src="{!URLFOR($Action.Attachment.Download, evententry.Attachments[0].Id)}" class="pull-left img-responsive" alt="" style="max-width:180px;max-height:100px"/&gt;                         {!evententry.Message__c}                      &lt;/p&gt;                        &lt;apex:outputLink styleclass="btn btn-sm btn-default" value="{!$Page.eh_eventdetails}?id={!evententry.id}"&gt;Read More&lt;/apex:outputLink&gt;                      &lt;/apex:outputPanel&gt;                 &lt;/div&gt;                 &lt;/apex:repeat&gt;                 &lt;/apex:form&gt;                 &lt;/apex:outputPanel&gt;                   &lt;/div&gt;             &lt;/div&gt;                 &lt;/section&gt;           &lt;/apex:define&gt; &lt;/apex:composition&gt;     Can anyone suggest how I can able to get the event data from the query and display it on a visualforce page in a repeat tag? I've tried everything and it doesn't work.  I've already tried passing the query from an anonymous user and the results were as expected
76641
I need to get item from list sharepoint by Id I use this code and it give me all the items of the list :  &lt;script&gt;  function parseURLParams(url) {         var queryStart = url.indexOf("?") + 1,             queryEnd = url.indexOf("#") + 1 || url.length + 1,             query = url.slice(queryStart, queryEnd - 1),             pairs = query.replace(/\+/g, " ").split("&amp;"),             parms = {}, i, n, v, nv;          if (query === url || query === "") {             return;         }          for (i = 0; i &lt; pairs.length; i++) {             nv = pairs[i].split("=");             n = decodeURIComponent(nv[0]);             v = decodeURIComponent(nv[1]);              if (!parms.hasOwnProperty(n)) {                 parms[n] = [];             }              parms[n].push(nv.length === 2 ? v : null);         }         return parms;     }  $( window ).load(function() {   var urlString = document.URL;  urlParams = parseURLParams(urlString);  ExecuteOrDelayUntilScriptLoaded(retrieveActualite, "sp.js");          var siteUrl = '/sites/securite';      function retrieveActualite() {              var clientContext = new SP.ClientContext(siteUrl);             var oList = clientContext.get_web().get_lists().getByTitle('Actualite');             var camlQuery = new SP.CamlQuery();              camlQuery.set_viewXml('&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=”ID” LookupId="TRUE"/&gt;&lt;Value Type="Text"&gt;' + urlParams.IdArt[0] + '&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;');             this.collListItem = oList.getItems(camlQuery);             clientContext.load(collListItem);             clientContext.executeQueryAsync(onQuerySucceededActualite, onQueryFailed);         }          function onQuerySucceededActualite(sender, args) {              var listItemInfo = '';              var listItemEnumerator = collListItem.getEnumerator();             while (listItemEnumerator.moveNext()) {                 var oListItem = listItemEnumerator.get_current();                   var desc=oListItem.get_item('Description');                 $('#idArticle').append('&lt;label class="titleArticle"&gt;'+oListItem.get_item('Title')+'&lt;/label&gt; &lt;br&gt;&lt;br&gt;&lt;p class="ContenuArticle" &gt;'+desc+'&lt;/p&gt;');                          }         }          function onQueryFailed(sender, args) {              alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());         }       });    &lt;/script&gt;   so how can I get only the considered item ?
110175
I am receiving an error stated above on line 26**(listAccount1)**, can anyone guide me on how to solve it?  public class FRB_UpdateExceptionsforBatch {    public static void FRB_Exceptions(){    string FRBRecordTypeID = utility.getFRBProfileNameLabel();       List&lt;Account&gt; lstAccount = new List&lt;Account&gt;();         List&lt;Account&gt; lstAccount1 = new List&lt;Account&gt;();         List&lt;Account&gt; lstAccount2 = new List&lt;Account&gt;();         List&lt;Account&gt; lstAccount3 = new List&lt;Account&gt;();    lstAccount = [Select id,FRB_Firm_Check__c,Number_of_Exception__c,Number_of_exceptions_under_4_6_bucket__c,Number_of_exceptions_under_7_10_bucket__c,Number_of_exceptions_under_11_19_bucket__c,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '0-3 Days (Green - New Exception)' ) FROM Account WHERE FRB_Firm_Check__c = TRUE];     if(lstAccount.size()&gt;0){           for( Account acc : lstAccount )           {               List&lt;Process_Adherence_Monitoring__c&gt; lstCont = acc.Process_Adherence_Monitoring__r;                acc.Number_of_Exception__c = lstCont.size();               acc.FRB_Firm_Check__c = true;           }            update lstAccount;     }         //To update 4-6 bucket      lstAccount1 = [select Id, Name,FRB_Firm_Check__c, Number_of_exceptions_under_4_6_bucket__c,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '4-6 Days (Yellow - Outside Correction Timeframe)' ) from Account where FRB_Firm_Check__c = TRUE];        if(lstAccount1.size()&gt;0){           for( Account acc : lstAccount1 )           {               List&lt;Process_Adherence_Monitoring__c&gt; lstCont1 = acc.Process_Adherence_Monitoring__r;                              acc.Number_of_exceptions_under_4_6_bucket__c= lstCont1.size();               acc.FRB_Firm_Check__c = true;           }            update lstAccount1 ;       }         //To update 6-11 bucket         lstAccount2 =  [select Id, Name,FRB_Firm_Check__c, Number_of_exceptions_under_7_10_bucket__c,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '7-10 Days (Orange - Approaching Critical Timeframe)' ) from Account where FRB_Firm_Check__c = TRUE];        if(lstAccount2.size()&gt;0){           for( Account acc : lstAccount2 )           {               List&lt;Process_Adherence_Monitoring__c&gt; lstCont2 = acc.Process_Adherence_Monitoring__r;                acc.Number_of_exceptions_under_7_10_bucket__c= lstCont2.size();               acc.FRB_Firm_Check__c = true;           }           update lstAccount2 ;       }        //To update 11 bucket            lstAccount3 =  [select Id, Name,FRB_Firm_Check__c, Number_of_exceptions_under_11_19_bucket__c,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '11-19 Days (Red - Immediate Correction Required)' ) from Account where FRB_Firm_Check__c = TRUE];        if(lstAccount3.size()&gt;0){           for( Account acc : lstAccount3 )           {               List&lt;Process_Adherence_Monitoring__c&gt; lstCont3 = acc.Process_Adherence_Monitoring__r;                acc.Number_of_exceptions_under_11_19_bucket__c= lstCont3.size();               acc.FRB_Firm_Check__c = true;           }                              update lstAccount3 ;       }      }   }
84853
Comment on Duplicate Reference: Why would this be marked duplicate when it was asked years prior to the question referenced as a duplicate?  I also believe the question, detail, and response is much better than the referenced question.  I've been a C++ programmer for quite a while but I'm new to Java and new to Eclipse.  I want to use the  to visualize some data I'm working with.  This code is organized like this:  ./com ./com/touchgraph ./com/touchgraph/graphlayout ./com/touchgraph/graphlayout/Edge.java ./com/touchgraph/graphlayout/GLPanel.java ./com/touchgraph/graphlayout/graphelements ./com/touchgraph/graphlayout/graphelements/GESUtils.java ./com/touchgraph/graphlayout/graphelements/GraphEltSet.java ./com/touchgraph/graphlayout/graphelements/ImmutableGraphEltSet.java ./com/touchgraph/graphlayout/graphelements/Locality.java ./com/touchgraph/graphlayout/graphelements/TGForEachEdge.java ./com/touchgraph/graphlayout/graphelements/TGForEachNode.java ./com/touchgraph/graphlayout/graphelements/TGForEachNodePair.java ./com/touchgraph/graphlayout/graphelements/TGNodeQueue.java ./com/touchgraph/graphlayout/graphelements/VisibleLocality.java ./com/touchgraph/graphlayout/GraphLayoutApplet.java ./com/touchgraph/graphlayout/GraphListener.java ./com/touchgraph/graphlayout/interaction ./com/touchgraph/graphlayout/interaction/DragAddUI.java ./com/touchgraph/graphlayout/interaction/DragMultiselectUI.java ./com/touchgraph/graphlayout/interaction/DragNodeUI.java ./com/touchgraph/graphlayout/interaction/GLEditUI.java ./com/touchgraph/graphlayout/interaction/GLNavigateUI.java ./com/touchgraph/graphlayout/interaction/HVRotateDragUI.java ./com/touchgraph/graphlayout/interaction/HVScroll.java ./com/touchgraph/graphlayout/interaction/HyperScroll.java ./com/touchgraph/graphlayout/interaction/LocalityScroll.java ./com/touchgraph/graphlayout/interaction/RotateScroll.java ./com/touchgraph/graphlayout/interaction/TGAbstractClickUI.java ./com/touchgraph/graphlayout/interaction/TGAbstractDragUI.java ./com/touchgraph/graphlayout/interaction/TGAbstractMouseMotionUI.java ./com/touchgraph/graphlayout/interaction/TGAbstractMousePausedUI.java ./com/touchgraph/graphlayout/interaction/TGSelfDeactivatingUI.java ./com/touchgraph/graphlayout/interaction/TGUIManager.java ./com/touchgraph/graphlayout/interaction/TGUserInterface.java ./com/touchgraph/graphlayout/interaction/ZoomScroll.java ./com/touchgraph/graphlayout/LocalityUtils.java ./com/touchgraph/graphlayout/Node.java ./com/touchgraph/graphlayout/TGAbstractLens.java ./com/touchgraph/graphlayout/TGException.java ./com/touchgraph/graphlayout/TGLayout.java ./com/touchgraph/graphlayout/TGLensSet.java ./com/touchgraph/graphlayout/TGPaintListener.java ./com/touchgraph/graphlayout/TGPanel.java ./com/touchgraph/graphlayout/TGPoint2D.java ./com/touchgraph/graphlayout/TGScrollPane.java ./TG-APACHE-LICENSE.txt ./TGGL ReleaseNotes.txt ./TGGraphLayout.html ./TGGraphLayout.jar   How do I add this project in Eclipse and get it compiling and running quickly?
93772
below is my code Created a wrapper class like below  public class ResponseWrapper{     public list&lt;Account&gt; lstaccounts;     public boolean isError ;     public string errorCode;     public integer statusCode;        public ResponseWrapper(){          lstaccounts = new list&lt;Account&gt;();          isError= false;     }  }   and returning the wrapper class in the Httpget method  @RestResource(urlMapping='/accounts/*') global with sharing class AccountRestService { @HttpGet global static ResponseWrapper getAccounts() {     ResponseWrapper resWrap = new ResponseWrapper();     List&lt;Account&gt; accounts;      try {         accounts = [SELECT Id, Name FROM Account];         res.lstaccounts = accounts;     } catch (Exception e) {         RestResponse res = RestContext.response;         resWrap.isError = true;         res.responseBody = Blob.valueOf(e.getMessage()) = resWrap.errorCode;         res.statusCode = 500 = resWrap.statusCode;     }      return resWrap;   } }   but its throwing the Error message  Error: Compile Error: global methods do not support return type of ResponseWrapper at line 4 column 31
4404
Im getting above error when i was trying to run my test class. In my test class i will create an Account, Contact. And this contact id will be used in my original code to create Community user.  I noticed following help article from SFDC. But couldn't figure out how to achieve.   Here they asked to create User on the Test class and Runas this user. But in my case, the community user will be created in the code. Please share any thoughts.  Here is the detailed exception,     System.DmlException: Insert failed. First exception on row 0; first   error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, caused by:   System.DmlException: Insert failed. First exception on row 11; first   error: UNKNOWN_EXCEPTION, portal account owner must have a role: []
86546
I have been trying to integrate Google Shortener API into my salesforce org. I wrote a class to make the call out, but am having difficulty bringing the value back into the record. I have a custom object called "referral_advocate__c" with a field called "Short_URL__c". Anytime the field "unique_ID__c" has a value, I am wanting to send this value with a static URL to google shortener and then save the response value to "referral_advocate__c.short_URL__c" on the record. This is the class to make the call out:  public class URLshort {  final string urls = 'https://www.myurl.com'; referral_advocate__c adv = new referral_advocate__c();  @future(callout = true) public static void URLshortner() {      HttpRequest req = new HttpRequest();     HttpResponse res = new HttpResponse();     Http http = new Http();      req.setEndpoint('https://www.googleapis.com/urlshortener/v1/url?key=myapikey');     req.setMethod('POST');     req.setHeader('Content-Type','application/json');            req.setBody('{"longUrl":+urls + adv.unique_reference_number_c}');       try {         res = http.send(req);         System.debug(res.getBody());     } catch(System.CalloutException e) {         System.debug('Callout error: '+ e);         System.debug(res.toString());     }   }  }   The after insert trigger on "referral_advocate__c" I wrote is not firing correctly. How do I return the results from this class and update the field "short_URL__C" with the returned value from a trigger?
7576
I have a lookup to a custom object called Project on my Opportunity object. I am trying to write a trigger that updates an Active, Awarded, and Title on the Project object whenever the Active, Awarded, or Title field is updated on Opportunity based some on more logic that isn't in my code below. This is my first trigger and needing a little help due to a NullPointerException where I try to set Project__r.Active__c = true. Any thoughts?      trigger ProjectFieldsTrigger on Opportunity (before insert, before update) {       //List&lt;Opportunity&gt; opp = [SELECT Name, Active__c, Funded__c, Title__c, Project__r.Name, Project__r.Active__c, Project__r.Awarded__c      //  FROM Opportunity WHERE Id IN :Trigger.New];      for(Opportunity o: Trigger.New){          if(o.Project__c != null){              if(o.Active__c == 'Y'){                 o.Project__r.Active__c = true;             }      }  }
57540
I'm trying to update an account list and I need to get the Ids when the update fails.  I use the getId() method but for accounts which fail I get null.  It's an update so my account already has an Id.  Is it normal ? If it is, how can I get the Ids list of non-updated accounts ?  Here is my code :  List&lt;Account&gt; accountsList = [select Id from Account];  for(Account a : accountsList) {     a.Name = 'Test', }  List&lt;Database.SaveResult&gt; res = Database.update(accountsList, false);  for (Database.SaveResult s : res) {     if (!s.isSuccess()) {         system.debug(s.getId()); // I get null here      }  }
74634
I am trying to start share-point workflow using CSOM(Client side object model) by following means of code. But i got the following error from the line mark in comment. Please help me to figure out this error.     Error :- Cannot invoke method or retrieve property from null   object. Object returned by the following call stack is null.   "GetWorkflowDeploymentService new   Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager() "    public bool StartWorkFlow()  {     string workflowName = "UpdateDealStatus";     // connect to the workflow services via a CSOM client context    var workflowServicesManager = new WorkflowServicesManager(_sharepoint,                  _sharepoint.Web);    // connect to the deployment service    var workflowDeploymentService = workflowServicesManager.GetWorkflowDeploymentService();    // get all installed workflows   var publishedWorkflowDefinitions =    workflowDeploymentService.EnumerateDefinitions(true);             _sharepoint.Load(publishedWorkflowDefinitions);     try    {       _sharepoint.ExecuteQuery();//Error thrown from this line    }    catch (Exception ex)    {      }     // find the first workflow definition    var firstWorkflowDefinition = publishedWorkflowDefinitions.First();     // connect to the subscription service    var workflowSubscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();     // get all workflow associations    var workflowAssociations = workflowSubscriptionService.EnumerateSubscriptionsByDefinition(firstWorkflowDefinition.Id);     _sharepoint.Load(workflowAssociations);    _sharepoint.ExecuteQuery();     foreach (var association in workflowAssociations)    {        Console.WriteLine("{0} - {1}",        association.Id, association.Name);    }     return true; }
16225
Why does it (apparently) make a difference whether I pass null as an argument directly, or pass an Object that I assigned the value null?  Object testVal = null; test.foo(testVal);    // dispatched to foo(Object) // test.foo(null);    // compilation problem -&gt; "The method foo(String) is ambiguous"     public void foo(String arg) { // More-specific     System.out.println("foo(String)"); }  public void foo(Object arg) { // Generic     System.out.println("foo(Object)"); }   In other words, why is the (commented-out) second call to foo(...) not dispatched to foo(Object)?  Update: I use Java 1.6. I could compile Hemal's code without problems, but mine still doesn't compile. The only difference I see is that Hemal's methods are static while mine are not. But I really don't see why this should make a difference...?  Update 2: Solved. I had another method foo(Runnable) in my class, so the dispatcher couldn't unambiguously select the single most specific method. (See my comment in Hemal's second answer.) Thanks everyone for your help.
5085
I´m having problems with url parameters (req.requestURI) in my test class.  This is my code.  REST CLASS:  @RestResource(urlMapping='/Accounts/*') global class StoreController {       @HttpGet     global static String getAccounts() {           integer pageNumber=integer.valueof(RestContext.request.params.get('page'));         string  ptime=RestContext.request.params.get('time');         string  hash=RestContext.request.params.get('hash');      }   REST TEST CLASS:  @isTest private class StoreControllerTest {      static testMethod void testGet() {       //do request     RestRequest req = new RestRequest();      RestResponse res = new RestResponse();      req.requestURI = 'https://dev-my-my.cs14.force.com/mine/services/apexrest/Accounts?page=0&amp;time=1390296387&amp;hash=1wer2547';         req.httpMethod = 'GET';     RestContext.request = req;     RestContext.response = res;          String results = StoreController.getAccounts();      } }   When i run test class i get the error:  System.NullPointerException: Argument 1 cannot be null    for line :  integer pageNumber=integer.valueof(RestContext.request.params.get('page'));   Looks like parameters are not taken from url ''  when i run the test class.Please can you help me with this?
112233
To communicate with a REST interface on a private system, I need to send a JSON message from a trigger. I have a message object that has some fields, lists and a child object:  public class MerchantConfig {  public class MIDConfig {     public String mid;     public String currencyCode;     public String cardTemplateName;     public String paymentPanelRestriction;     public List&lt;String&gt; restrictedCountries;      public String paymentPanelRestrictionForCountries; }  public String merchantName; public String sopgTemplateName; public Integer dispositionTimeWindowInMinutes; public List&lt;String&gt; features; public Boolean activateImmediately; public List&lt;MIDConfig&gt; midConfiguration; }   I can serialize it to JSON using the built-in serializer:  String body = JSON.serializePretty([MerchantConfig instance]);   The result:  {   "sopgTemplateName" : null,   "midConfiguration" : [ {     "restrictionCountries" : [ "DE", "AT" ],     "paymentPanelRestrictionForCountries" : "MANDATORY",     "paymentPanelRestriction" : "OPTIONAL",     "mid" : "1000000001",     "currencyCode" : "EUR",     "cardTemplateName" : null   }, {     "restrictionCountries" : [ ],     "paymentPanelRestrictionForCountries" : "",     "paymentPanelRestriction" : "OPTIONAL",     "mid" : "1000000002",     "currencyCode" : "USD",     "cardTemplateName" : null   }, {     "restrictionCountries" : [ ],     "paymentPanelRestrictionForCountries" : "",     "paymentPanelRestriction" : "PROHIBITED",     "mid" : "1000000003",     "currencyCode" : "AUD",     "cardTemplateName" : null   } ],   "merchantName" : "Test Merchant",   "features" : [ XYZ ],   "dispositionTimeWindowInMinutes" : 10,   "activateImmediately" : true }   How can I serialize this object so that all properties that are null don't show up in the JSON string?   In this example, "sopgTemplateName" and all "cardTemplateName" properties are null and should not appear in the JSON string. The empty list "restrictionCountries" should still appear as an empty list, though.