• Nidhi Malhotra
  • NEWBIE
  • 45 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 5
    Replies
Hi All,

I need help in creating triggers that sends outbound messages to a specific URL. Initially we created workflows to send Outbound messages. We have to create certain logic before sending these outbound messages and hence we are taking the approach of creating Triggers. I used the WSDLtoApex feature in Salesforce. Four additional classes have beenc reated. I would like to know how I can use these classes in the trigger or any other Apex code. Any help on this will be highly appreciated!

Thanks,
Nidhi

 
Hi All,
 
I need urgent help with a Visual force page. Following are the requirements:
  • When we click the new button on the Contact object, a visual force page should be displayed
  • In the first section we will show few fields related to the Contact for user to enter. This is already taken care
  • Next section allow users to add multiple related items (Custom object called Shares) dynamically. A new row can be added when user clicks Add Row button. Maximum of 5 rows can be entered.
  • Each row must display the following fields First Name, Last Name, Email, Relationship, ‘Is Contact Eligible’?
  • Is Contact eligible field is a pick list with values Yes or No, it should be shown as Checkbox.
    • If Is Contact Eligible is checked then four fields Home Phone, Mobile Phone, Other Phone, Work Phone must be show in the same row.
    • This means initial five fields in a Row and additional four fields must be display when Is Contact Eligible checkbox is checked.
  • A Delete button should be available in the end of each row so that we can delete the row.
  • When user saves the rows should be saved in custom object and associated to the Contact.
I can do the new button and saving part. But am facing it difficult to bring the custom object in rows and also properly formatted and aligned.

If anyone can help me with this Visual force page and design, it would be greatly helpful.
Thanks,
Nidhi
Hi All,

This is really urgent. Somone please help me.

I have set up users for Chatter only users. The user I am testing is part of many groups. But when I login to the Salesforce1 app --> Click the left hand navigation menu --> then click on Groups. I do not see any Groups in the list. This is very very much important for us.

There is a item called Smart Search Items in the mobile navigation menu , I tried removing it and adding. But no luck.

Could anyone please let us know if I am missing any configuration setting here? Please help me here.

Thanks,
Nidhi M
Hi All,

This is really urgent. Somone please help me.

I have set up users for Chatter only users. The user I am testing is part of many groups. But when I login to the Salesforce1 app --> Click the left hand navigation menu --> then click on Groups. I do not see any Groups in the list. This is very very much important for us.

There is a item called Smart Search Items in the mobile navigation menu , I tried removing it and adding. But no luck.

Could anyone please let us know if I am missing any configuration setting here? Please help me here.

Thanks,
Nidhi M
Hi All,

I have set up users for Chatter only users. The user I am testing is part of many groups. But when I login to the Salesforce1 app --> Click the left hand navigation menu --> then click on Groups. I do not see any Groups in the list. This is very very much important for us.

There is a item called Smart Search Items in the mobile navigation menu , I tried removing it and adding. But no luck.

Could anyone please let us know if I am missing any configuration setting here? Please help me here.

Thanks,
Nidhi M
Hi All,

I am trying to create a VF page to upload users's chatter profile picture. I know about the OOB way but we have a requirement to upload it using Visual force pages. 

Following is the code that I have developed. But I am recieving the following error. Please help me to troubleshoot this or if there is any workaround. I am okay to use any other fuction, but once the user uploads an image that has to be set as her profile. Even if that is cropped automatically and saved that is fine, or if we can even crop it that also will be great. 

I recieve following error: ConnectApi.ConnectApiException: Illegal value for parameter: 'fileId': 015L0000000ENip
Error is in expression '{!upload}' in component <apex:commandButton> in page profilephotoupload

An unexpected error has occurred. Your solution provider has been notified. (ConnectApi)

Following is the code. 

VF Page:

<apex:page controller="FileUploadController">
  <apex:sectionHeader title="Visualforce Example" subtitle="File Upload Example"/>

  <apex:form enctype="multipart/form-data">
    <apex:pageMessages />
    <apex:pageBlock title="Upload a File">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!document.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!document.description}" id="description"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Keywords" for="keywords"/>
          <apex:inputText value="{!document.keywords}" id="keywords"/>
        </apex:pageBlockSectionItem>

      </apex:pageBlockSection>

    </apex:pageBlock>
  </apex:form>
</apex:page>

Controller:

public without sharing class FileUploadController {

  public Document document {
    get {
      if (document == null)
        document = new Document();
      return document;
    }
    set;
  }

  public PageReference upload() {
    Id ImageId;
    document.AuthorId = UserInfo.getUserId();
    document.FolderId = UserInfo.getUserId(); // put it in running user's folder

    try {
      document.type = 'jpg'; 
      document.IsPublic = true;
      insert document;
      ImageId = document.id;
      //ConnectApi.ChatterUsers newPhoto = new ConnectApi.ChatterUsers();
         
   
   
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
      return null;
    } finally {
      document.body = null; // clears the viewstate
      document = new Document();
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully : '+ImageId ));
    String communityId = null;
    String userId= UserInfo.getUserId();
    ID fileId = ImageId;

    // Set photo
    ConnectApi.Photo photo = ConnectApi.ChatterUsers.setPhoto(communityId, userId, fileId, null);
    return null;
  }

}

Thanks a lot,
Nidhi M
Hi All the experts out there! I need your help with the following code.

I am trying to replicate the custom My Profile Visual force page. I am using the standard Visual force page and controller that was available in the instance.

I modified it and commented certain lines. After commenting certain lines I found that the Command buttons are not functioning properly.
The reason I commented some pageblock section tags and all is that I want this page to be custom. I will add other header and logos using HTML. I also want only certain fields to be editable. That is the reason I have commented certain lines.

But after doing so, the command buttons itself does not function. Or when I try to click it, I am not even able to click it.

Can anyone please help me to fix this? All that I want is that this page to be functional with few fields but no standard salesforce styling inside that. If everything is in wile background also that is also great. I even want to retain the change password function. Also the change password page should not have standard salesforce syling.

Please help me to fix this issue.

Regards,
Nidhi

Apex Page ~~~~~~~~~~~~~~~~~~~~~~~

<apex:page id="portalUserProfilePage" controller="CustomMyProfilePageController" showHeader="false" title="{!$Label.site.my_profile_page}">
  <!-- <apex:composition template="{!$Site.Template}"> -->
  <html>
  <body>
    <!-- <apex:define name="body"> -->
        <apex:form id="theForm">
          <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetail" rendered="{!isEdit}">
           <!-- <apex:pageBlock title="{!$Label.site.my_profile}" id="editUserDetail" rendered="{!isEdit}"> -->
             <apex:pageMessages />
             <!-- <apex:pageBlockButtons id="editButtons" location="top"> -->
               <apex:commandButton id="save" value="{!$Label.site.save}" action="{!save}" rerender="userDetail"/>
               <apex:commandButton id="cancel" value="{!$Label.site.cancel}" action="{!cancel}" rerender="userDetail" immediate="true"/>
             <!-- </apex:pageBlockButtons> -->
             <apex:pageBlockSection id="editUserSection" columns="1" title="{!$Label.site.user_information}">
                 <apex:inputField id="editusername" value="{!user.username}"/>
                 <apex:inputField id="edittimezone" value="{!user.timezonesidkey}"/>
                 <apex:inputField id="editlocale" value="{!user.localesidkey}"/>
                 <apex:inputField id="editlanguage" value="{!user.languagelocalekey}"/>
                 <apex:inputField id="editcommunityNickname" value="{!user.communityNickname}"/>
             </apex:pageBlockSection>
             <apex:pageBlockSection id="editContactSection" columns="2" title="{!$Label.site.contact_information}">
                 <apex:inputField id="editfirstName" value="{!user.firstName}"/>
                 <apex:inputField id="editemail" value="{!user.email}"/>
                 <apex:inputField id="editlastName" value="{!user.lastName}"/>
                 <apex:inputField id="editphone" value="{!user.phone}"/>
                 <apex:inputField id="edittitle" value="{!user.title}"/>
                 <apex:inputField id="editextension" value="{!user.extension}"/>
                 <apex:pageBlockSectionItem />
                 <apex:inputField id="editfax" value="{!user.fax}"/>
                 <apex:pageBlockSectionItem />
                 <apex:inputField id="editmobile" value="{!user.mobilephone}"/>
               </apex:pageBlockSection>
               <apex:pageBlockSection id="editAddressInformation" columns="1" title="{!$Label.site.address_information}">
                 <apex:inputField id="editstreet" value="{!user.street}"/>
                 <apex:inputField id="editcity" value="{!user.city}"/>
                 <apex:inputField id="editstate" value="{!user.state}"/>
                 <apex:inputField id="editpostalcode" value="{!user.postalcode}"/>
                 <apex:inputField id="editcountry" value="{!user.country}"/>
               </apex:pageBlockSection>
           <!-- </apex:pageBlock>     -->  
             </apex:outputPanel>
           
             <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetails" rendered="{!!isEdit}">
            <!-- <apex:pageBlock title="{!$Label.site.my_profile}" id="viewUserDetail" rendered="{!!isEdit}"> -->
                 <!-- <apex:pageBlockButtons id="detailButtons" location="top"> -->
                   <apex:commandButton id="edit" value="{!$Label.site.edit}" action="{!edit}" rerender="userDetail"/>
                   <apex:commandButton id="changePassword" value="{!$Label.site.change_password}" action="{!changePassword}"/>
                 <!-- </apex:pageBlockButtons> -->
                 <!-- <apex:pageBlockSection id="viewUserSection" columns="2" title="{!$Label.site.user_information}"> -->
                     <!-- <apex:outputField id="detailusername" value="{!user.username}"/>
                     <apex:outputField id="detailtimezone" value="{!user.timezonesidkey}"/>
                     <apex:outputField id="detaillocale" value="{!user.localesidkey}"/>
                     <apex:outputField id="detaillanguage" value="{!user.languagelocalekey}"/>
                     <apex:outputField id="detailcommunityNickname" value="{!user.communityNickname}"/> -->
                 <!-- </apex:pageBlockSection> -->
                 <!-- <apex:pageBlockSection id="viewContactSection" columns="2" title="{!$Label.site.contact_information}"> -->
                     <b>Email : </b> <apex:outputField id="detailemail" value="{!user.email}"/> <br/>
                     <b>Name : </b><apex:outputField id="detailfirstName" value="{!user.firstName}"/> <br/>
                     <!-- <b></b><apex:outputField id="detaillastName" value="{!user.lastName}"/> -->
                     <b>Title : </b><apex:outputField id="detailtitle" value="{!user.title}"/> <br/>
                     <!-- <apex:outputField id="detailphone" value="{!user.phone}"/>
                     <apex:outputField id="detailstreet" value="{!user.street}"/>
                     <apex:outputField id="detailcity" value="{!user.city}"/>
                     <apex:outputField id="detailstate" value="{!user.state}"/>
                     <apex:outputField id="detailpostalcode" value="{!user.postalcode}"/>
                     <apex:outputField id="detailcountry" value="{!user.country}"/>
                     <apex:outputField id="detailextension" value="{!user.extension}"/>
                     <apex:outputField id="detailfax" value="{!user.fax}"/>
                     <apex:outputField id="detailmobile" value="{!user.mobilephone}"/> -->
                 <!--</apex:pageBlockSection> -->
               <!-- </apex:pageBlock> -->
            </apex:outputPanel>
         </apex:form>
    <!-- </apex:define> -->
    </body>
    </html>
<!-- </apex:composition> -->
</apex:page>



Controller ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
/**
* An apex class that keeps updates of a portal user in sync with its corresponding contact.
   Guest users are never able to access this page.
*/
public with sharing class CustomMyProfilePageController {

    private User user;
    private boolean isEdit = false;

    public User getUser() {
        return user;
    }

    public CustomMyProfilePageController() {
        user = [SELECT id, email, username, usertype, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                FROM User
                WHERE id = :UserInfo.getUserId()];
        // guest users should never be able to access this page
        if (user.usertype == 'GUEST') {
            throw new NoAccessException();
        }
    }

    public Boolean getIsEdit() {
        return isEdit;
    }

    public void edit() {
        isEdit=true;
    }

    public void save() {
        if (user.contact != null) {
            setContactFields(user.contact, user);
        }

        try {
            update user;
            if (user.contact != null) {
                update user.contact;
            }
            isEdit=false;
        } catch(DmlException e) {
            ApexPages.addMessages(e);
        }
    }

    public PageReference changePassword() {
        return Page.ChangePassword;
    }

    public void cancel() {
        isEdit=false;
        user = [SELECT id, email, username, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                FROM User
                WHERE id = :UserInfo.getUserId()];
    }

    public static void setContactFields(Contact c, User u) {
        c.title = u.title;
        c.firstname = u.firstname;
        c.lastname = u.lastname;
        c.email = u.email;
        c.phone = u.phone;
        c.mobilephone = u.mobilephone;
        c.fax = u.fax;
        c.mailingstreet = u.street;
        c.mailingcity = u.city;
        c.mailingstate = u.state;
        c.mailingpostalcode = u.postalcode;
        c.mailingcountry = u.country;
    }
}
Hi All the experts out there! I need your help with the following code.

I am trying to replicate the custom My Profile Visual force page. I am using the standard Visual force page and controller that was available in the instance.

I modified it and commented certain lines. After commenting certain lines I found that the Command buttons are not functioning properly.
The reason I commented some pageblock section tags and all is that I want this page to be custom. I will add other header and logos using HTML. I also want only certain fields to be editable. That is the reason I have commented certain lines. 

But after doing so, the command buttons itself does not function. Or when I try to click it, I am not even able to click it.

Can anyone please help me to fix this? All that I want is that this page to be functional with few fields but no standard salesforce styling inside that. If everything is in wile background also that is also great. I even want to retain the change password function. Also the change password page should not have standard salesforce syling.

Please help me to fix this issue.

Regards,
Nidhi

Apex Page ~~~~~~~~~~~~~~~~~~~~~~~

<apex:page id="portalUserProfilePage" controller="CustomMyProfilePageController" showHeader="false" title="{!$Label.site.my_profile_page}">
  <!-- <apex:composition template="{!$Site.Template}"> -->
  <html>
  <body>
    <!-- <apex:define name="body"> -->
        <apex:form id="theForm">
          <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetail" rendered="{!isEdit}">
           <!-- <apex:pageBlock title="{!$Label.site.my_profile}" id="editUserDetail" rendered="{!isEdit}"> -->
             <apex:pageMessages />
             <!-- <apex:pageBlockButtons id="editButtons" location="top"> -->
               <apex:commandButton id="save" value="{!$Label.site.save}" action="{!save}" rerender="userDetail"/>
               <apex:commandButton id="cancel" value="{!$Label.site.cancel}" action="{!cancel}" rerender="userDetail" immediate="true"/>
             <!-- </apex:pageBlockButtons> -->
             <apex:pageBlockSection id="editUserSection" columns="1" title="{!$Label.site.user_information}">
                 <apex:inputField id="editusername" value="{!user.username}"/>
                 <apex:inputField id="edittimezone" value="{!user.timezonesidkey}"/>
                 <apex:inputField id="editlocale" value="{!user.localesidkey}"/>
                 <apex:inputField id="editlanguage" value="{!user.languagelocalekey}"/>
                 <apex:inputField id="editcommunityNickname" value="{!user.communityNickname}"/>
             </apex:pageBlockSection>
             <apex:pageBlockSection id="editContactSection" columns="2" title="{!$Label.site.contact_information}">
                 <apex:inputField id="editfirstName" value="{!user.firstName}"/>
                 <apex:inputField id="editemail" value="{!user.email}"/>
                 <apex:inputField id="editlastName" value="{!user.lastName}"/>
                 <apex:inputField id="editphone" value="{!user.phone}"/>
                 <apex:inputField id="edittitle" value="{!user.title}"/>
                 <apex:inputField id="editextension" value="{!user.extension}"/>
                 <apex:pageBlockSectionItem />
                 <apex:inputField id="editfax" value="{!user.fax}"/>
                 <apex:pageBlockSectionItem />
                 <apex:inputField id="editmobile" value="{!user.mobilephone}"/>
               </apex:pageBlockSection>
               <apex:pageBlockSection id="editAddressInformation" columns="1" title="{!$Label.site.address_information}">
                 <apex:inputField id="editstreet" value="{!user.street}"/>
                 <apex:inputField id="editcity" value="{!user.city}"/>
                 <apex:inputField id="editstate" value="{!user.state}"/>
                 <apex:inputField id="editpostalcode" value="{!user.postalcode}"/>
                 <apex:inputField id="editcountry" value="{!user.country}"/>
               </apex:pageBlockSection>
           <!-- </apex:pageBlock>     -->   
             </apex:outputPanel>
            
             <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetails" rendered="{!!isEdit}">
            <!-- <apex:pageBlock title="{!$Label.site.my_profile}" id="viewUserDetail" rendered="{!!isEdit}"> -->
                 <!-- <apex:pageBlockButtons id="detailButtons" location="top"> -->
                   <apex:commandButton id="edit" value="{!$Label.site.edit}" action="{!edit}" rerender="userDetail"/>
                   <apex:commandButton id="changePassword" value="{!$Label.site.change_password}" action="{!changePassword}"/>
                 <!-- </apex:pageBlockButtons> -->
                 <!-- <apex:pageBlockSection id="viewUserSection" columns="2" title="{!$Label.site.user_information}"> -->
                     <!-- <apex:outputField id="detailusername" value="{!user.username}"/>
                     <apex:outputField id="detailtimezone" value="{!user.timezonesidkey}"/>
                     <apex:outputField id="detaillocale" value="{!user.localesidkey}"/>
                     <apex:outputField id="detaillanguage" value="{!user.languagelocalekey}"/>
                     <apex:outputField id="detailcommunityNickname" value="{!user.communityNickname}"/> -->
                 <!-- </apex:pageBlockSection> -->
                 <!-- <apex:pageBlockSection id="viewContactSection" columns="2" title="{!$Label.site.contact_information}"> -->
                     <b>Email : </b> <apex:outputField id="detailemail" value="{!user.email}"/> <br/>
                     <b>Name : </b><apex:outputField id="detailfirstName" value="{!user.firstName}"/> <br/>
                     <!-- <b></b><apex:outputField id="detaillastName" value="{!user.lastName}"/> -->
                     <b>Title : </b><apex:outputField id="detailtitle" value="{!user.title}"/> <br/>
                     <!-- <apex:outputField id="detailphone" value="{!user.phone}"/>
                     <apex:outputField id="detailstreet" value="{!user.street}"/>
                     <apex:outputField id="detailcity" value="{!user.city}"/>
                     <apex:outputField id="detailstate" value="{!user.state}"/>
                     <apex:outputField id="detailpostalcode" value="{!user.postalcode}"/>
                     <apex:outputField id="detailcountry" value="{!user.country}"/>
                     <apex:outputField id="detailextension" value="{!user.extension}"/>
                     <apex:outputField id="detailfax" value="{!user.fax}"/>
                     <apex:outputField id="detailmobile" value="{!user.mobilephone}"/> -->
                 <!--</apex:pageBlockSection> -->
               <!-- </apex:pageBlock> -->
            </apex:outputPanel>
         </apex:form>
    <!-- </apex:define> -->
    </body>
    </html>
<!-- </apex:composition> -->
</apex:page>



Controller ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
/**
* An apex class that keeps updates of a portal user in sync with its corresponding contact.
   Guest users are never able to access this page.
*/
public with sharing class CustomMyProfilePageController {

    private User user;
    private boolean isEdit = false;

    public User getUser() {
        return user;
    }

    public CustomMyProfilePageController() {
        user = [SELECT id, email, username, usertype, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                FROM User
                WHERE id = :UserInfo.getUserId()];
        // guest users should never be able to access this page
        if (user.usertype == 'GUEST') {
            throw new NoAccessException();
        }
    }

    public Boolean getIsEdit() {
        return isEdit;
    }

    public void edit() {
        isEdit=true;
    }

    public void save() {
        if (user.contact != null) {
            setContactFields(user.contact, user);
        }

        try {
            update user;
            if (user.contact != null) {
                update user.contact;
            }
            isEdit=false;
        } catch(DmlException e) {
            ApexPages.addMessages(e);
        }
    }

    public PageReference changePassword() {
        return Page.ChangePassword;
    }

    public void cancel() {
        isEdit=false;
        user = [SELECT id, email, username, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                FROM User
                WHERE id = :UserInfo.getUserId()];
    }

    public static void setContactFields(Contact c, User u) {
        c.title = u.title;
        c.firstname = u.firstname;
        c.lastname = u.lastname;
        c.email = u.email;
        c.phone = u.phone;
        c.mobilephone = u.mobilephone;
        c.fax = u.fax;
        c.mailingstreet = u.street;
        c.mailingcity = u.city;
        c.mailingstate = u.state;
        c.mailingpostalcode = u.postalcode;
        c.mailingcountry = u.country;
    }
}
Hi All,

Could you please help me to let me know why get and set is used in Salesforce Apex? And how is it used and how gettter and setter methods are defined and even the differences.

Thanks,
Nidhi
Hi All,

Me new to salesforce. I need a help here. I want to develop a visualforce page where there is a text box. When we type something in the text box, I want to search the item entered in the account object and show in a table. Also If possible while typing we need to show sugesstions like Auto fill.

When the rowns are displayed there must be a button when click, it must execute some Controller function.

How do I start with this? Please help!

Thanks,
Nidhi M
Hi All,

I am very new to salesforce development. Please help me with this issue. I need a visual force page with the following:
  • Visualforce page displaying all the Members of a specified group.
  • A remove button next to the each member
  • Once we click on the Remove button, the controller function has to be called.
I have done all the above, but when I click the Remoe button I am calling a Javascript function. That JS function calls the ActionFunction. But the Action function is not getting executed. How do we pass the paramete inside action function?

Please help me here.

Thanks,
Nidhi Malhotra
Hi All,

I am trying to create a VF page to upload users's chatter profile picture. I know about the OOB way but we have a requirement to upload it using Visual force pages. 

Following is the code that I have developed. But I am recieving the following error. Please help me to troubleshoot this or if there is any workaround. I am okay to use any other fuction, but once the user uploads an image that has to be set as her profile. Even if that is cropped automatically and saved that is fine, or if we can even crop it that also will be great. 

I recieve following error: ConnectApi.ConnectApiException: Illegal value for parameter: 'fileId': 015L0000000ENip
Error is in expression '{!upload}' in component <apex:commandButton> in page profilephotoupload

An unexpected error has occurred. Your solution provider has been notified. (ConnectApi)

Following is the code. 

VF Page:

<apex:page controller="FileUploadController">
  <apex:sectionHeader title="Visualforce Example" subtitle="File Upload Example"/>

  <apex:form enctype="multipart/form-data">
    <apex:pageMessages />
    <apex:pageBlock title="Upload a File">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!document.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!document.description}" id="description"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Keywords" for="keywords"/>
          <apex:inputText value="{!document.keywords}" id="keywords"/>
        </apex:pageBlockSectionItem>

      </apex:pageBlockSection>

    </apex:pageBlock>
  </apex:form>
</apex:page>

Controller:

public without sharing class FileUploadController {

  public Document document {
    get {
      if (document == null)
        document = new Document();
      return document;
    }
    set;
  }

  public PageReference upload() {
    Id ImageId;
    document.AuthorId = UserInfo.getUserId();
    document.FolderId = UserInfo.getUserId(); // put it in running user's folder

    try {
      document.type = 'jpg'; 
      document.IsPublic = true;
      insert document;
      ImageId = document.id;
      //ConnectApi.ChatterUsers newPhoto = new ConnectApi.ChatterUsers();
         
   
   
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
      return null;
    } finally {
      document.body = null; // clears the viewstate
      document = new Document();
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully : '+ImageId ));
    String communityId = null;
    String userId= UserInfo.getUserId();
    ID fileId = ImageId;

    // Set photo
    ConnectApi.Photo photo = ConnectApi.ChatterUsers.setPhoto(communityId, userId, fileId, null);
    return null;
  }

}

Thanks a lot,
Nidhi M
Hi All,
 
I need urgent help with a Visual force page. Following are the requirements:
  • When we click the new button on the Contact object, a visual force page should be displayed
  • In the first section we will show few fields related to the Contact for user to enter. This is already taken care
  • Next section allow users to add multiple related items (Custom object called Shares) dynamically. A new row can be added when user clicks Add Row button. Maximum of 5 rows can be entered.
  • Each row must display the following fields First Name, Last Name, Email, Relationship, ‘Is Contact Eligible’?
  • Is Contact eligible field is a pick list with values Yes or No, it should be shown as Checkbox.
    • If Is Contact Eligible is checked then four fields Home Phone, Mobile Phone, Other Phone, Work Phone must be show in the same row.
    • This means initial five fields in a Row and additional four fields must be display when Is Contact Eligible checkbox is checked.
  • A Delete button should be available in the end of each row so that we can delete the row.
  • When user saves the rows should be saved in custom object and associated to the Contact.
I can do the new button and saving part. But am facing it difficult to bring the custom object in rows and also properly formatted and aligned.

If anyone can help me with this Visual force page and design, it would be greatly helpful.
Thanks,
Nidhi
Hi All,

This is really urgent. Somone please help me.

I have set up users for Chatter only users. The user I am testing is part of many groups. But when I login to the Salesforce1 app --> Click the left hand navigation menu --> then click on Groups. I do not see any Groups in the list. This is very very much important for us.

There is a item called Smart Search Items in the mobile navigation menu , I tried removing it and adding. But no luck.

Could anyone please let us know if I am missing any configuration setting here? Please help me here.

Thanks,
Nidhi M
Hi,
    Whenever a user is assigned multiple leads a email gets sent to the owner informing him of this after 5 mins. We have a wokflow on User and based on the field value on the User the workflow is triggered. The email gets sent to the correct user i.e the owner of the leads but the merge fields on the template considers the values of the user who assigned the user to the leads. Could anyone please let me know the reason behind this incorrect merge field values .


Thanks,
Nisha
  • May 08, 2014
  • Like
  • 0
Hi All,

Me new to salesforce. I need a help here. I want to develop a visualforce page where there is a text box. When we type something in the text box, I want to search the item entered in the account object and show in a table. Also If possible while typing we need to show sugesstions like Auto fill.

When the rowns are displayed there must be a button when click, it must execute some Controller function.

How do I start with this? Please help!

Thanks,
Nidhi M
Hi All,

I am very new to salesforce development. Please help me with this issue. I need a visual force page with the following:
  • Visualforce page displaying all the Members of a specified group.
  • A remove button next to the each member
  • Once we click on the Remove button, the controller function has to be called.
I have done all the above, but when I click the Remoe button I am calling a Javascript function. That JS function calls the ActionFunction. But the Action function is not getting executed. How do we pass the paramete inside action function?

Please help me here.

Thanks,
Nidhi Malhotra