• Forcedotcom737
  • NEWBIE
  • 50 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies
Best way to handle many - many relationship between User & Business Unit. One user can belong to many business units & a business unit can be associated with several users.

Soln: Create junction object with lookup to standard user object & lookup to custom Business Unit object which captures the business units.

Concern with soln: User needs to be maintained in the custom junction object as well as the standard user object. I would prefer a solution where once user is added / deleted with Business unit info the junction object should be automatically updated.In my solution the standard user object does not capture business unit information (because of many-many relationship). The link with business unit and user is made in the junction object. This means the user in the user object is not linked with the business unit. The solution seems clunky. Any suggestions on how this can be accomplished?
Any ideas on a SFDC.com based native solution (not buying third pary app's) that can scan call records / notes and identify keywords (based on a word list) in the call records. The solutions goal is to identify inappropriate words in call notes (e.g the word bribe).

Possible Solution (Need help with solving point 4 or open to completely new ideas):

1. Create a table / List / object with the word list that needs to be scanned (e.g the word 'bribe' would be in that list)
2. Export existing call record data into a database and perform a SQL join with 'word list' to identify calls with the word bribe (this will be a monthly process)
3. Load the suspect calls back into SFDC for examination by say managers / auditors etc

4. Is there a way to highlight the words that were picked up by the SQL process in the call notes that were identified as suspect. Perhaps a SFDC formatting class that maybe available. This is the part that I dont have an initial solution for. The goal is to make it easier for a manager to know which word caused the call note to be flagged without having to manually scan for words in the call note.

Also although this is not ideal are you aware of any third party solutions that can do this? 
With reference to the line of code (method createContact) below I am wondering where  List<candidate_c> candidateFromTrigger is created? This doesn’t seem to follow the create new list syntax

 public void createContact(List<Candidate_c> candidateFromTrigger)

 Is this statement not required somewhere in the code to create the new List candidateFromTrigger

E.g List<candidate_c> candidateFromTrigger = new List <candidate_c>(); (I was expecting this kind of stament in the code. I am new to apex & coding)

Goal of the code:

Access method from trigger by passing trigger.new to createContact

A.createContact(trigger.new)
Trying to understand relationship queries. Could you please review the quesries that wont work below and comment on what I am doing incorrectly?

I have 2 objects:
Festivals__c (Parent Object to Attendee)
Attendee object has two lookup fields Account & Festivals (name of festival)

These wont work

 (Trying to query Attendee Name, Tickets purchased and Festival Name (Master-Detail); going from child to parent)

SELECT Name,Tickets_Purchased__c,Festivals__r.Name FROM Attendee__c

 (Trying to Query  festival Name and attendee name - going from parent to child)

SELECT Festivals__c.Name, (SELECT Name FROM Attendee__C) FROM Festivals__c

 (Trying to Query Attendee Name, tickets purchased and lookup Account)

 SELECT Name,Tickets_Purchased__c,Account.Name FROM Attendee__c

 These statements work:

SELECT First_Name__c,Tickets_Purchased__c  FROM Attendee__c

 SELECT Festivals__c.Name FROM Festivals__c

 SELECT Name FROM Attendee__C

Sample Error Messages:

Didn't understand relationship 'Festivals__r' in field path.

Didn't understand relationship 'Attendee__C'

Didn't understand relationship 'Account' in field path
1. Contact c = new Contact();

For the statement above is 'c' an instance of the class Contact hence making it an object of the class Contact? Is Contact (standard object) a class which salesforce refers to as sObjects?

2. t.WhatId = a.id  ('t' is an instance of the standard object task and 'a' is an instance of the standard object Account)

2.1 Could you explain whats going on in the above statement? An example would be helpful.
My guess: In the statement above the record id of created account 'a' being associated with the new task created. The id (in the task object) is a foreign key linked to the account object. 

2.2  The Id fields dont seem to be listed as object fields when viewing the fields (customize objects>fields). Whats the best way to locate the id fields in sObjects. Is it via reports? Any alternatives?

3. c.AccountId = at.Account__c; The goal of this statement is to make the account in the attendee (at) object (lookup to account) appear in the newly created contact (c). See code below.

Why would these statements not work? :
c.Account = at.Account__c
OR 
c.AccountId = at.Account__cId (linking the Id's)

*************************
Refrence code which uses the above statements:
trigger CreateContact on Attendee__c (after insert, after update) {

List <Contact> contactToInsert = new List <Contact>();
for(Attendee__c at :Trigger.new){

Contact c = new Contact();

c.Division__c = at.Division__c;

c.FirstName = at.First_Name__c;
c.LastName = at.Last_Name__c;
c.AccountId = at.Account__c;

contactToInsert.add(c);

}

insert contactToInsert;

}

-------
trigger CreateFlowupTask on Account (after insert,after update) {


// Created collection for saving new tasks
List <task> taskToInsert = new List <task> ();

//Trigger new is the list of all new accounts

for (Account a : Trigger.new) {
task t = new task ();
t.Subject = 'Call';
t.Status = 'Not Started';
t.Priority = 'Normal';

t.WhatId = a.id;

taskToInsert.add(t);

}

insert taskToInsert;

}
Trying to learn apex by attempting to write simple triggers.

Could you please review the code below and suggest changes so First Name & Last Name (common fields between attendee and contact) information is copied over to the contact object when a new attendee is created in the custom attendee object. Also I couldnt find the field names for first name and last name in the contact object (Contact>Fields). Had to comment out a few lines to allow the code to compile. The division field is a custom field on both attendee and contact.


trigger CreateContact on Attendee__c (after insert, after update) {

List <Contact> contactToInsert = new List <Contact>();
for(Attendee__c at :Trigger.new){

Contact c = new Contact();

c.Division__c = at.Division__c;

//c.First Name = at.First_Name__c; // couldnt fin field name in the contact object. Found Field label.
//c.Last Name = at.Last_Name__c;

//contactToInsert.add(at); //compile error

}

insert contactToInsert;

}
I am very new to apex coding. Please see trigger below which creates a task when a ticket is raised with priority high. The trigger works except for this line : // t.Owner = Tickets__c.Assigned_To__c;

I am trying to pick up the the user to whom the ticket is assigned via field Assigned_To__c in the custom ticket object and then create a task where the owner of the task is the same user as the 'Assigned to' field captures in the ticket object.

What do I need to do to pick up the user captured in a field (Assigned to) in a custom object (ticket) and then assign the same user as owner of a task? 

Trigger compiles except for the commented line:

trigger AssignTicket on Tickets__c (after insert,after update) {

for(Tickets__c tkt : trigger.new){

if(tkt.Priority__c == 'High'){

task t = new task();

t.Subject = 'Ticket has been assigned to you!';
t.Status = 'Not Started';
t.Priority = 'Normal';
//t.Owner = Tickets__c.Assigned_To__c.;

t.WhatId = tkt.id;

       insert t;
                            }


                                 }
 
Best way to handle many - many relationship between User & Business Unit. One user can belong to many business units & a business unit can be associated with several users.

Soln: Create junction object with lookup to standard user object & lookup to custom Business Unit object which captures the business units.

Concern with soln: User needs to be maintained in the custom junction object as well as the standard user object. I would prefer a solution where once user is added / deleted with Business unit info the junction object should be automatically updated.In my solution the standard user object does not capture business unit information (because of many-many relationship). The link with business unit and user is made in the junction object. This means the user in the user object is not linked with the business unit. The solution seems clunky. Any suggestions on how this can be accomplished?
Any ideas on a SFDC.com based native solution (not buying third pary app's) that can scan call records / notes and identify keywords (based on a word list) in the call records. The solutions goal is to identify inappropriate words in call notes (e.g the word bribe).

Possible Solution (Need help with solving point 4 or open to completely new ideas):

1. Create a table / List / object with the word list that needs to be scanned (e.g the word 'bribe' would be in that list)
2. Export existing call record data into a database and perform a SQL join with 'word list' to identify calls with the word bribe (this will be a monthly process)
3. Load the suspect calls back into SFDC for examination by say managers / auditors etc

4. Is there a way to highlight the words that were picked up by the SQL process in the call notes that were identified as suspect. Perhaps a SFDC formatting class that maybe available. This is the part that I dont have an initial solution for. The goal is to make it easier for a manager to know which word caused the call note to be flagged without having to manually scan for words in the call note.

Also although this is not ideal are you aware of any third party solutions that can do this? 
Trying to understand relationship queries. Could you please review the quesries that wont work below and comment on what I am doing incorrectly?

I have 2 objects:
Festivals__c (Parent Object to Attendee)
Attendee object has two lookup fields Account & Festivals (name of festival)

These wont work

 (Trying to query Attendee Name, Tickets purchased and Festival Name (Master-Detail); going from child to parent)

SELECT Name,Tickets_Purchased__c,Festivals__r.Name FROM Attendee__c

 (Trying to Query  festival Name and attendee name - going from parent to child)

SELECT Festivals__c.Name, (SELECT Name FROM Attendee__C) FROM Festivals__c

 (Trying to Query Attendee Name, tickets purchased and lookup Account)

 SELECT Name,Tickets_Purchased__c,Account.Name FROM Attendee__c

 These statements work:

SELECT First_Name__c,Tickets_Purchased__c  FROM Attendee__c

 SELECT Festivals__c.Name FROM Festivals__c

 SELECT Name FROM Attendee__C

Sample Error Messages:

Didn't understand relationship 'Festivals__r' in field path.

Didn't understand relationship 'Attendee__C'

Didn't understand relationship 'Account' in field path
I am very new to apex coding. Please see trigger below which creates a task when a ticket is raised with priority high. The trigger works except for this line : // t.Owner = Tickets__c.Assigned_To__c;

I am trying to pick up the the user to whom the ticket is assigned via field Assigned_To__c in the custom ticket object and then create a task where the owner of the task is the same user as the 'Assigned to' field captures in the ticket object.

What do I need to do to pick up the user captured in a field (Assigned to) in a custom object (ticket) and then assign the same user as owner of a task? 

Trigger compiles except for the commented line:

trigger AssignTicket on Tickets__c (after insert,after update) {

for(Tickets__c tkt : trigger.new){

if(tkt.Priority__c == 'High'){

task t = new task();

t.Subject = 'Ticket has been assigned to you!';
t.Status = 'Not Started';
t.Priority = 'Normal';
//t.Owner = Tickets__c.Assigned_To__c.;

t.WhatId = tkt.id;

       insert t;
                            }


                                 }