• Mattias Nordin
  • NEWBIE
  • 75 Points
  • Member since 2008

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 22
    Replies

Hi, Sites looks like fun. This is my first test. Can someone help me by explaining how you pass on the contact ID to the site page. The problem im having is whenever i test (dont know if i use the correct syntax) i get the...

 

"Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it. "

 

...message. Im using the following apex code on my page:

 

 

 <apex:page standardController="Contact" sidebar="false" showHeader="false">

  <h1>Mattias visual force concept page2</h1>

    <apex:form id="theForm">
     First name =  <apex:outputField value="{!contact.FirstName}"/>
    </apex:form>

</apex:page>

 

And access the page with the following URL:

 

http://flir.force.com/test/

 

So far so good.

 

But when i try to add the contact id using:

 

http://flir.force.com/test/?id=0032000000QRu5B

 

I get the authorization requred message. What am i doing wrong?

 

 

Hi,

 

Im thinking of writing a trigger that capture the last modified date of all related list on the account and to store the latest last modified date on the account.

 

What whould be the best method to accomplish this? Create the trigger on the account and get the information from all related items or to create a trigger on each related item?

 

I want the trigger to execute whenever any related item such as an activity or a note has been added.

Is it possible to create a visual force page containing information from three different objects?

 

I want to show some details from the Opportunity.

Some details from SAP__c

Some details from SFDC_520_Quote__c

 

The SAP__c object has a reference to the SFDC_520_quote__c object BUT there is no reference between the quote object and the opportunity (except the opportunity id). A script populate the opportunity with data when the quote is saved (custom solution).

 

 

SAP_id is the only input i have. I guess the other data would be accessable via something like...

 

SAP info --> SELECT A, quote_id FROM SAP__c WHERE SAP_ID = "123"

 

Quote info --> SELECT A, opportunity_id FROM SFDC_520_quote__c WHERE quote_id = variableQuoteId

 

Opportunity info --> SELECT A, B, C FROM Opportunity WHERE opportunity_id = variableOpportunityId

 


My goal is to display the following information on my visual force email template:

 

{!SAP.name}

{!SAP.created_date}

 

{!QUOTE.name}

{!QUOTE.created_date}

 

{!OPPORTUNITY.name}

{!OPPORTUNITY.created_date}

Only a few of my users needs to have the unlimited version. Some need to have professional. Can i mix the two in the same organisation?

It is nice that it is possible to set values in some fields in the task window by passing them into the window via the url. Anyone have the full list of supported query strings?

 

 

I have found the following to be working:

 

Window title:    ?title={!... text ...}
Assigned to:     &tsk1={!User.id}
Name:            &tsk2={!Contact.id}       or use    &what_id={!Contact.id}
Related to:      &tsk3={!Opportunity.id}   or use    &who_id={!Opportunity.id} 
Due Date:        &tsk4={!...date...}
Subject:         &tsk5={!...text...}
Comments:        &tsk6={!...text...}
???:             &tsk7= ???
???:             &tsk8= ???
???:             &tsk9= ???
Type:            &tsk10={!... Must be an existing picklist value ...}
Return url:      &retURL={!Opportunity.id}
???:             &followup= ???

 

 Example of a link that pre populates a task with subject and comment text. It also tries to connect the "Related to" and the "Name" lookup.

 

https://xxx.my.salesforce.com/00T/e?title=Call&who_id=00120000007erYY&what_id=0062000000B6wEZ&followup=0&tsk5=Subject Text Goes Here&tsk6=Comment text goes here&retURL=%2F0062000000B6wEZ

 

Anyone have more info about this please post below.

 

 

 

Hi all Gurus,

 

I have created a visualforce page that shows quote information. The purpose is to have this information sent to the order office when the quote is won.

 

I have created a data quality check that is executed before the page is posted. If data is not correct the field itself will be a link to the page holding that field (account page, contact page or opportunity page).

 

I have found the following knowledge article that is interesting...

https://help.salesforce.com/apex/HTViewSolution?id=104305&language=en

 

  

  

QUESTION:
How do i create a link that opens the contact page and redirects back to my other page when/if the contact page is saved?

 

I have tried several times but not found the right syntax yet. The page is not redirecting back after save. Please advice...

This is the link that i use to open the contact page

 

onDblClick="document.location.href='https://flir.my.salesforce.com/{!Opportunity.sold_to_contact__r.Id}'"

 

I have tried the following:

 

onDblClick="document.location.href='https://flir.my.salesforce.com/{!Opportunity.sold_to_contact__r.Id}?saveURL=%2F00120000009QdoSAAS'"

 

 Above does not work.

 

  • Anyone know if this should be possible to accomplish???

 

 Thanks

 

Hi,

 

I have created a visualForce page that displays information from different objects in sales force (copied to the opportunity object via formulas).

 

Instead of adding the products via a related list i would prefer to build my own. I need to show different columns then i have on the opportunty.

 

<p><apex:relatedList list="OpportunityLineItems" pageSize="1000"/></p>

 

How can you loop the line items in any other way?

How do i execute a mailmerge on a hardcoded template on a click of a button on the opportunity object in sales force?

Is this possible?

Im trying to use a apex script that i have found. But it seems like it does not take care of the problem of opportunities not having a primary contact. If the primary contact is not defined it throws the following error.

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger trgMnCopyPrimaryContact caused an unexpected exception, contact your administrator: trgMnCopyPrimaryContact: execution of BeforeUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.trgMnCopyPrimaryContact: line 6, column 13

 

trigger trgMnCopyPrimaryContact on Opportunity (before update) {

   for (Opportunity o : Trigger.new) {

       OpportunityContactRole contactRole =
            [select ContactID from OpportunityContactRole where IsPrimary = true and OpportunityId = :o.id];

       if (contactRole != null) {
         o.Opportunity_contact__c = contactRole.ContactID;
       }

   }

 }

 

 

Im not a java developer and wonder if someone can help me to add functionality that does not fail if the primary contact is missing.

I was hoping that it would be possible to build a visual page showing price book information. To get started i need to know the name of the standard controller for the price book.

Anyone know the syntax?

 

/ Mattias

How do you execute an apex trigger on lead convert?

I noticed that a lead convert is not an edit action.

 

Thanks

Mattias

Since we have all our partners as accounts in Sales Force using sales force as the database for displaying contact info on our external web seems like a smart idea.

 

But how do you get started. I realize that i need to use sites to accomplish it but i don't know how to loop the list and how to create the query.

 

This need seems to me to be something others would have allready done. Is there an example code out there that points me in the right direction?

 

Best regards
Mattias

Im trying to convert the following javascript to java code but have a hard time since im new to the java syntax.

 

Can someone please help me to get started.

 

JAVASCRIPT&colon;

 

varFieldScore = 0
varFieldCounter = 0

funAddScore("{!Opportunity.Name}")
funAddScore("{!Opportunity.Type}")
funAddScore("{!Opportunity.NextStep}")

// FUNCTION
function funAddScore(iField){
varFieldCounter = varFieldCounter +1
if( iField.length > 1){
varFieldScore = varFieldScore +1
}
}

varPercent = varFieldScore / varFieldCounter * 100
varPercent = Math.round(varPercent)

alert("varFieldScore=" +varFieldScore +" varFieldCounter= " +varFieldCounter +" varPercent =" +varPercent )

 

 

I havent come far with the java version. The output should be in a field called "field score" on the opportunity object.

 

JAVA VERSION:

 

trigger trgMnTest on Opportunity(before update) {

    // SET VARIABLE
    Private integer intCountScore = 0;
    Private integer intFieldCount = 0;

    private Opportunity[] oppObj = Trigger.new;
  
    // TEST FIELD AMOUNT
    intFieldCount = intFieldCount +1;
    if(oppObj[0].Amount > 0){
    intCountScore = intCountScore +10;
    }
 
   
   oppObj[0].NextStep = 'Hello World ' +intCountScore;

}

 

 

PS THIS FORUM THROWS AN ERROR WHEN POSTING USING IE8. PLEASE FIX DS
Idea: http://sites.force.com/ideaexchange/ideaView?c=09a30000000D9xt&id=087300000007Mj0AAE

 

 

Message Edited by Mattias Nordin on 02-02-2010 01:26 AM

Hi,

 

Im trying to do a list of the top 10 contact rows. Is it possible to select TOP10 or something similar?

Is there a referece document of the SQL syntax or is it standard SQL?

 

 

This is the class im experimenting with.

 

public with sharing class RepeatCon {

    List<Contact> pos = [SELECT TOP10 Id, Name FROM Contact];

    public List<Contact> getPos() {
        return pos;
    }

}

 

Note that i dont know much about APAX yet.

Hi all gurus. Im new to sites but am loving it.

 

How do you get the contact owner name?

 

Hi,

 

Im thinking of writing a trigger that capture the last modified date of all related list on the account and to store the latest last modified date on the account.

 

What whould be the best method to accomplish this? Create the trigger on the account and get the information from all related items or to create a trigger on each related item?

 

I want the trigger to execute whenever any related item such as an activity or a note has been added.

Hi,

 

In the default  'Contacts' tab, there is a 'Send an Email'  button in the Activity History section.

Clicking on the 'Send an Email' button brings up a nice VF page to send email.

 

I want a similar functionality in my app. How do I access the same VF page to send email?

 

thanks

svidyan

Only a few of my users needs to have the unlimited version. Some need to have professional. Can i mix the two in the same organisation?

 

Hi all Gurus,

 

I have created a visualforce page that shows quote information. The purpose is to have this information sent to the order office when the quote is won.

 

I have created a data quality check that is executed before the page is posted. If data is not correct the field itself will be a link to the page holding that field (account page, contact page or opportunity page).

 

I have found the following knowledge article that is interesting...

https://help.salesforce.com/apex/HTViewSolution?id=104305&language=en

 

  

  

QUESTION:
How do i create a link that opens the contact page and redirects back to my other page when/if the contact page is saved?

 

I have tried several times but not found the right syntax yet. The page is not redirecting back after save. Please advice...

This is the link that i use to open the contact page

 

onDblClick="document.location.href='https://flir.my.salesforce.com/{!Opportunity.sold_to_contact__r.Id}'"

 

I have tried the following:

 

onDblClick="document.location.href='https://flir.my.salesforce.com/{!Opportunity.sold_to_contact__r.Id}?saveURL=%2F00120000009QdoSAAS'"

 

 Above does not work.

 

  • Anyone know if this should be possible to accomplish???

 

 Thanks

 

With Winter '11, if you create a Site, a new Salesforce-provided class gets deployed to your org: MyProfilePageController.cls

 

There is test code in this class that fails if you don't have a portal user installed. This prevents you from doing anything in that org that requires running all tests.

 

Here is the error:

 

System.QueryException: List has no rows for assignment to SObject

Class.MyProfilePageController.testSave: line 78, column 35 External entry point

 

and the line in question:

 

 

User existingPortalUser = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId <> null AND UserType='CustomerSuccess' LIMIT 1];

 

This failure prevents doing any save from Eclipse. You can't deploy new code, edit object metadata files, etc. Complete showstopper.

 

Can anyone:

 * confirm this (we think reproducing will require that you create a new Site, perhaps the first Site in the org, after Winter 11)

 * think of a work-around (tried enabling self-service portal, but it doesn't create the required user type)

 

Anyone from Salesforce confirm that this is a bug and not something we're doing wrong?

 

Thanks!

 

Here is the entire class:

 

/**
 * 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 class MyProfilePageController {

    private User user;
    private boolean isEdit = false;
    
    public User getUser() {
        return user;
    }

    public MyProfilePageController() {
        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);
        }
        
        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()];
    }
    
    private void setContactFields(Contact c) {
        c.title = user.title;
        c.firstname = user.firstname;
        c.lastname = user.lastname;
        c.email = user.email;
        c.phone = user.phone;
        c.mobilephone = user.mobilephone;
        c.fax = user.fax;
        c.mailingstreet = user.street;
        c.mailingcity = user.city;
        c.mailingstate = user.state;
        c.mailingpostalcode = user.postalcode;
        c.mailingcountry = user.country;
    }

    static testMethod void testSave() {         
        // Modify the test to query for a portal user that exists in your org
        User existingPortalUser = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId <> null AND UserType='CustomerSuccess' LIMIT 1];
        System.assert(existingPortalUser != null, 'This test depends on an existing test portal user to run');
        
        String randFax = Math.rint(Math.random() * 1000) + '5551234';
        
        System.runAs(existingPortalUser) {
            MyProfilePageController controller = new MyProfilePageController();
            System.assertEquals(existingPortalUser.Id, controller.getUser().Id, 'Did not successfully load the current user');
            System.assert(controller.isEdit == false, 'isEdit should default to false');
            controller.edit();
            System.assert(controller.isEdit == true);
            
            controller.cancel();
            System.assert(controller.isEdit == false);
            
            controller.getUser().Fax = randFax;
            controller.save();
            System.assert(controller.isEdit == false);
        }
        
        // verify that the user and contact were updated
        existingPortalUser = [Select id, fax, Contact.Fax from User where id =: existingPortalUser.Id];
        System.assert(existingPortalUser.fax == randFax);
        System.assert(existingPortalUser.Contact.fax == randFax);
    }

}

 

 

 

  • October 15, 2010
  • Like
  • 0

With the new API 20.0 version, seems like we get access to photos using SmallPhotoUrl and FullPhotoUrl, but seems like i need to have my salesforce session while accessing these images.

 

I have 2 requirements:

 

1. Way to download the image (get Image method)

2. Or an external shared image which can be accessed without salesforce session,

 

Is it possible with new API 20?

Hi,

 

Can someone explain to me how to write a test class for an apex trigger like the following one?

 

trigger trgMnUpdateContactFieldsFromUserTable on Contact (before update, before insert) {

    Set<Id> userIds = new Set<Id>();
    for (Contact a : Trigger.new)
        userIds.add(a.OwnerId);
    
    // Query the User table for the associated fields you need and place in a map.
    Map<Id, User> fields = new Map<Id, User>([select Name, User_Region__c from User where id in :userIds]);
    
    // Now use the map to set the appropriate fields on every Account processed by the trigger.
    for (Contact a : Trigger.new) {
        
        // OWNER NAME FROM USER TO ACCOUNT
        a.Owner_name_txt__c = fields.get(a.OwnerId).Name;

        // OWNER REGION FROM USER TO ACCOUNT
        a.Owner_region__c = fields.get(a.OwnerId).User_Region__c;

    }    
}

 

Hi,

 

I have created a visualForce page that displays information from different objects in sales force (copied to the opportunity object via formulas).

 

Instead of adding the products via a related list i would prefer to build my own. I need to show different columns then i have on the opportunty.

 

<p><apex:relatedList list="OpportunityLineItems" pageSize="1000"/></p>

 

How can you loop the line items in any other way?

How do i execute a mailmerge on a hardcoded template on a click of a button on the opportunity object in sales force?

Is this possible?

Im trying to use a apex script that i have found. But it seems like it does not take care of the problem of opportunities not having a primary contact. If the primary contact is not defined it throws the following error.

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger trgMnCopyPrimaryContact caused an unexpected exception, contact your administrator: trgMnCopyPrimaryContact: execution of BeforeUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.trgMnCopyPrimaryContact: line 6, column 13

 

trigger trgMnCopyPrimaryContact on Opportunity (before update) {

   for (Opportunity o : Trigger.new) {

       OpportunityContactRole contactRole =
            [select ContactID from OpportunityContactRole where IsPrimary = true and OpportunityId = :o.id];

       if (contactRole != null) {
         o.Opportunity_contact__c = contactRole.ContactID;
       }

   }

 }

 

 

Im not a java developer and wonder if someone can help me to add functionality that does not fail if the primary contact is missing.

Hi,

 

I am trying to connect to SalesForce using Classic ASP.   I have downloaded the "SForce Office Toolkit.msi" version 4 and installed on my web server.  I attempted to use this code below (found in this forum), but could connect to SalesForce. 

<%
Dim SforceApi
Dim sObject(0)
 
Set SforceApi = server.CreateObject("SForceOfficeToolkit4.SForceSession4.0")

if SforceApi.Login("mylogin","mypassword_and_securityToken") then
    Set sObject(0) = SforceApi.CreateObject("Lead")
   
    sObject(0).Item("FirstName").value = "Test"
    sObject(0).Item("LastName").value = "Testing"

     if SforceApi.Create(sObject,false) then
         Response.Write "Correct insert "
     else
          Response.Write "Error on insert"
     end if
else
     response.Write "login failed"
end if

Set SforceApi = nothing
Set sObject(0) = nothing
%>

 

Any advice, please?

Since we have all our partners as accounts in Sales Force using sales force as the database for displaying contact info on our external web seems like a smart idea.

 

But how do you get started. I realize that i need to use sites to accomplish it but i don't know how to loop the list and how to create the query.

 

This need seems to me to be something others would have allready done. Is there an example code out there that points me in the right direction?

 

Best regards
Mattias

Im trying to convert the following javascript to java code but have a hard time since im new to the java syntax.

 

Can someone please help me to get started.

 

JAVASCRIPT&colon;

 

varFieldScore = 0
varFieldCounter = 0

funAddScore("{!Opportunity.Name}")
funAddScore("{!Opportunity.Type}")
funAddScore("{!Opportunity.NextStep}")

// FUNCTION
function funAddScore(iField){
varFieldCounter = varFieldCounter +1
if( iField.length > 1){
varFieldScore = varFieldScore +1
}
}

varPercent = varFieldScore / varFieldCounter * 100
varPercent = Math.round(varPercent)

alert("varFieldScore=" +varFieldScore +" varFieldCounter= " +varFieldCounter +" varPercent =" +varPercent )

 

 

I havent come far with the java version. The output should be in a field called "field score" on the opportunity object.

 

JAVA VERSION:

 

trigger trgMnTest on Opportunity(before update) {

    // SET VARIABLE
    Private integer intCountScore = 0;
    Private integer intFieldCount = 0;

    private Opportunity[] oppObj = Trigger.new;
  
    // TEST FIELD AMOUNT
    intFieldCount = intFieldCount +1;
    if(oppObj[0].Amount > 0){
    intCountScore = intCountScore +10;
    }
 
   
   oppObj[0].NextStep = 'Hello World ' +intCountScore;

}

 

 

PS THIS FORUM THROWS AN ERROR WHEN POSTING USING IE8. PLEASE FIX DS
Idea: http://sites.force.com/ideaexchange/ideaView?c=09a30000000D9xt&id=087300000007Mj0AAE

 

 

Message Edited by Mattias Nordin on 02-02-2010 01:26 AM

It appears the Contact Role is an embedded related list in the code and therefore I can't trigger a field update on conversion to set this checkbox. I was able to find the file using sforce explorer but don't know the best option to implement around it. Contact Role Primary = "o.IsPrimary"

 

It would appear that all converted LEADs into an Opp would have this defaulted to Primary since that is where the primary opp came from. 


Thanks,