How can I get the name of the lead owner in the Lead command line field?

I have an application that reads Lead records from Salesforce through the API, and I want to associate the Lead Owner field with an attribute in the application. The Lead Owner field does not appear in the list of available fields, but all custom fields are executed.

So, my first attempt at a solution was to create a custom field displaying the name of the lead owner. In the SF formula editor, as far as I can tell, it does not display the actual data field, but displays the ID string. This is pretty pointless in the context that I need.

alt text http://skinny.fire-storm.net/forposting/insertfield.JPG

Is there a way we can get data in an object that refers to an ID string?

alt text http://skinny.fire-storm.net/forposting/havewant.JPG

I have a RED BOX, but I need a GREEN BOX.

EDIT: I cannot change the application code calling the API. I can only change Salesforce. Thus, this is more of a superuser question for sales / design-writer, rather than a question of writing code that calls the SF API.

+3
source share
4 answers

Salesforce allows access to related data through what they call query relationships . Instead of connecting, you specify the request as follows:

System.debug ([SELECT Owner.Name FROM Lead WHERE Id = '00QS00000037lvv']. Owner.Name);

Try to run this in the syslog, just replace the identifier of the host with the one you are looking at.

API , - Lead.Owner.Name.

EDIT:

eyecream, , Apex - . :

trigger Lead_UpdateOwner on Lead(before insert, before update)
{
    Map<Id, String> ownerMap = new Map<Id, String>();
    for (Lead lead : Trigger.new)
    {
        ownerMap.put(lead.OwnerId, null);
    }

    if (ownerMap.size() > 0)
    {
        for (User[] users : [SELECT Id, Name FROM User WHERE Id IN :ownerMap.keySet()])
        {
            for (Integer i=0; i<users.size(); i++)
            {
                ownerMap.put(users[i].Id, users[i].Name);
            }
        }
        for (Lead lead : Trigger.new)
        {
            lead.OwnerName__c = ownerMap.get(lead.OwnerId);
        }
    }
}

lead.OwnerName__c , . , 121.

+5

, , . ,   OwnerLookup " ", . , Opportunity:

trigger OpportunityTrigger on Opportunity (before insert, after insert, before update, after update) {
    if(trigger.isBefore && trigger.isInsert) {
        OpportunityTriggerHandler.newOpportunity(Trigger.old, Trigger.new);
    }    
    else if(trigger.isAfter && trigger.isInsert){
        //OpportunityTriggerHandler.futureUse(Trigger.new);
    }
    else if(trigger.isBefore  && trigger.isUpdate){
        OpportunityTriggerHandler.updateOpportunity(Trigger.new, Trigger.oldMap);
    }
    else if(trigger.isAfter && trigger.isUpdate){
        //OpportunityTriggerHandler.futureUse(Trigger.new, Trigger.oldMap);
    }
}

OpportunityTriggerHandler ( Apex):

public with sharing class OpportunityTriggerHandler {
    public static void newOpportunity( List<Opportunity> oldOpportunitys, List<Opportunity> newOpportunitys ) {
        for (Opportunity opp: newOpportunitys) {
            updateOwnerData( opp );
        }
    }

    public static void updateOpportunity( List<Opportunity> oldOpportunitys, Map<Id, Opportunity> newOpportunitys ) {
        for (Opportunity opp: oldOpportunitys) {
            updateOwnerData( opp );
        }
    }

    public static void updateOwnerData( Opportunity opp ) {
        opp.OwnerLookup__c = opp.OwnerId;
    }
}

Opportunity/Account, (), " ":

OwnerLookup__r.FirstName & " " & OwnerLookup__r.LastName
+3

VLOOKUP ,

  • ,
  • ,

,

SELECT Owner.FirstName, Owner.LastName FROM Lead

... - , ?

+2

( Google): , , , , ( ) .

, , :

BLANKVALUE(Owner:Queue.QueueName, Owner:User.FirstName & " " & Owner:User.LastName)

, BLANKVALUE , owner.queuename , , .

+1

Source: https://habr.com/ru/post/1741364/


All Articles