• StephenYS10000
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 19
    Replies

How would one create a workflow that would fire an outbound message when a record is deleted from the source object?

 

Thanks

 

Stephen

I have a Account that submits an outbound message when ever an account is alerted.

The outbound message communicates with an application that collects an ID and then updates the Account with this new ID.

 

How could one implement a solution whereby the Account page is automatically refreshed once the ID is updated on the Account?

 

Thanks

 

Stephen

I have created a custom object that operates similiar to the Account Contact role object.

 

What is want the code below to do is to make sure that only one record can be marked as Primary at time.

I a user updates a record and marks it as Primary the trigger code will in turn find other records where Primary is equal to true and will change it to false.

 

I get the following error implement the trigger code as shown below

Developer script exception from 'test' : AccountContactRole_SetPrimary : AccountContactRole_SetPrimary: execution of BeforeUpdate caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old Trigger. AccountContactRole_SetPrimary: line 17, column

 

trigger AccountContactRole_SetPrimary on Account_Contact_Role__c (after update) { // Validate if the Primary and the combination of the contact and the role is not duplicated for the relevant account List <Account_Contact_Role__c> acrList = new List<Account_Contact_Role__c>(); for (Account_Contact_Role__c acr: Trigger.New){ Id CurrentId = acr.Id; if (acr.Primary__c == true){ for (Account_Contact_Role__c acrP : [SELECT Id FROM Account_Contact_Role__c WHERE Id !=: acr.Id and Primary__c = true]){ acrP.Primary__c = false; acrList.add(acr); } } } if (!acrList.isEmpty()){ update acrList; } }

 

 

 

I have created a custom related object to the Account object.

 

My client wants custom button that will allow one to create a new Contact from the section.

 

Could someboby please advise me on how to do this?

 

Thanks

 

Stephen

Hi All

 

I struggling to find material to help study for the DEV401 exam

 

 

Could someboby help answer this question?

 

How many master detail relationships can you have on an object?

Hi

 

I'm trying to link a custom field from the Account object that will create a picklist based on data from a custom lookup object

It works but I'm having problems getting to selected the current record value and to save the current picklist value to the Account record

 

Thanks in advance for you help

 

 

apex:page standardController="Account" >  <apex:form >  <tr><td>Municapaly</td><td>   <p>test {!account.Municipaly__c}</p>       <c:Municapaly_Dynamic_Picklist defaultvalue="(!account.Municipaly__c"> </c:Municapaly_Dynamic_Picklist>   </td>  <tr>    </apex:form></apex:page>              <apex:component controller="clsMuniciplayDynamicPicklist" ><apex:attribute name="defaultvalue" description="Dynamic Picklist value" type="String" required="true"></apex:attribute>  <apex:selectList value="{!defaultvalue}" size="1"><apex:selectOptions value="{!items}"></apex:selectOptions></apex:selectList></apex:component>  public class clsMuniciplayDynamicPicklist{    private Account CurrentAccount;        public string defaultvalue{get;set;}          private List<SelectOption> items;        public List<SelectOption> getItems() {         List<SelectOption> items = new List<SelectOption>();          for (Lookup_Tables__c lt: [Select l.Type__c, l.Start_Date__c, l.Name, l.End_Date__c, l.Code__c From Lookup_Tables__c l]){           items.add(new SelectOption( lt.Code__c,lt.Name));                 } 

I have create a custom object (child= that is linked to the Account  (master)

 

I want to create a custom button on the custom object that will allow one to create a new contact.

 

Does anybody know how I should create the url behind this button?

 

Thanks

 

Stephen

I was wondering if somebody could help me. I have create a dynamic picklist controller that collects it select list from a custom lookup table

I have a custom field called Municapaly on the Account object and I would like to link and update this field from this new controller 

 

<apex:page standardController="Account" >  <apex:form >  <tr><td>Municapaly</td><td>   <c:Municapaly_Dynamic_Picklist myvalue="1"> </c:Municapaly_Dynamic_Picklist>   </td>  <tr>

  </apex:form></apex:page>  <apex:page standardController="Account" >

  <apex:form >  <tr><td>Municapaly</td><td>   <c:Municapaly_Dynamic_Picklist myvalue="1"> </c:Municapaly_Dynamic_Picklist>   </td>  <tr>

  </apex:form></apex:page>  public class clsMuniciplayDynamicPicklist{    private List<SelectOption> items;       public List<SelectOption> getItems() {         List<SelectOption> items = new List<SelectOption>();         //default value         items.add(new SelectOption('','--Select Record Type --'));        

        for (Lookup_Tables__c lt: [Select l.Type__c, l.Start_Date__c, l.Name, l.End_Date__c, l.Code__c From Lookup_Tables__c l]){           items.add(new SelectOption( lt.Code__c,lt.Name));                 }            return items;     }

}

 
 

Does anybody know how I can populate a picklist from a trigger

 

My client whats the picklist to be dynamic

Is it possible to populate the picklist using Apex code from a class or a trigger?

 

I appears that it can be done using the Salesforce API but I can't find any examples where this can be done directly in Salesforce using the native apex code.

 

Thanks

 

Stephen

I have created a custom object that operates similiar to the Account Contact role object.

 

What is want the code below to do is to make sure that only one record can be marked as Primary at time.

I a user updates a record and marks it as Primary the trigger code will in turn find other records where Primary is equal to true and will change it to false.

 

I get the following error implement the trigger code as shown below

Developer script exception from 'test' : AccountContactRole_SetPrimary : AccountContactRole_SetPrimary: execution of BeforeUpdate caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old Trigger. AccountContactRole_SetPrimary: line 17, column

 

trigger AccountContactRole_SetPrimary on Account_Contact_Role__c (after update) { // Validate if the Primary and the combination of the contact and the role is not duplicated for the relevant account List <Account_Contact_Role__c> acrList = new List<Account_Contact_Role__c>(); for (Account_Contact_Role__c acr: Trigger.New){ Id CurrentId = acr.Id; if (acr.Primary__c == true){ for (Account_Contact_Role__c acrP : [SELECT Id FROM Account_Contact_Role__c WHERE Id !=: acr.Id and Primary__c = true]){ acrP.Primary__c = false; acrList.add(acr); } } } if (!acrList.isEmpty()){ update acrList; } }

 

 

 

We are seeking to increase our developer resources and am seeking those who have passed the certification exam or have the ability to do so.  Likewise we are also seeking to bring on one new certified consultant who has passed the consultant certification exam.

I have created a custom related object to the Account object.

 

My client wants custom button that will allow one to create a new Contact from the section.

 

Could someboby please advise me on how to do this?

 

Thanks

 

Stephen

Hi All

 

I struggling to find material to help study for the DEV401 exam

 

 

Could someboby help answer this question?

 

How many master detail relationships can you have on an object?

Hi

 

I'm trying to link a custom field from the Account object that will create a picklist based on data from a custom lookup object

It works but I'm having problems getting to selected the current record value and to save the current picklist value to the Account record

 

Thanks in advance for you help

 

 

apex:page standardController="Account" >  <apex:form >  <tr><td>Municapaly</td><td>   <p>test {!account.Municipaly__c}</p>       <c:Municapaly_Dynamic_Picklist defaultvalue="(!account.Municipaly__c"> </c:Municapaly_Dynamic_Picklist>   </td>  <tr>    </apex:form></apex:page>              <apex:component controller="clsMuniciplayDynamicPicklist" ><apex:attribute name="defaultvalue" description="Dynamic Picklist value" type="String" required="true"></apex:attribute>  <apex:selectList value="{!defaultvalue}" size="1"><apex:selectOptions value="{!items}"></apex:selectOptions></apex:selectList></apex:component>  public class clsMuniciplayDynamicPicklist{    private Account CurrentAccount;        public string defaultvalue{get;set;}          private List<SelectOption> items;        public List<SelectOption> getItems() {         List<SelectOption> items = new List<SelectOption>();          for (Lookup_Tables__c lt: [Select l.Type__c, l.Start_Date__c, l.Name, l.End_Date__c, l.Code__c From Lookup_Tables__c l]){           items.add(new SelectOption( lt.Code__c,lt.Name));                 } 

I have create a custom object (child= that is linked to the Account  (master)

 

I want to create a custom button on the custom object that will allow one to create a new contact.

 

Does anybody know how I should create the url behind this button?

 

Thanks

 

Stephen

I was wondering if somebody could help me. I have create a dynamic picklist controller that collects it select list from a custom lookup table

I have a custom field called Municapaly on the Account object and I would like to link and update this field from this new controller 

 

<apex:page standardController="Account" >  <apex:form >  <tr><td>Municapaly</td><td>   <c:Municapaly_Dynamic_Picklist myvalue="1"> </c:Municapaly_Dynamic_Picklist>   </td>  <tr>

  </apex:form></apex:page>  <apex:page standardController="Account" >

  <apex:form >  <tr><td>Municapaly</td><td>   <c:Municapaly_Dynamic_Picklist myvalue="1"> </c:Municapaly_Dynamic_Picklist>   </td>  <tr>

  </apex:form></apex:page>  public class clsMuniciplayDynamicPicklist{    private List<SelectOption> items;       public List<SelectOption> getItems() {         List<SelectOption> items = new List<SelectOption>();         //default value         items.add(new SelectOption('','--Select Record Type --'));        

        for (Lookup_Tables__c lt: [Select l.Type__c, l.Start_Date__c, l.Name, l.End_Date__c, l.Code__c From Lookup_Tables__c l]){           items.add(new SelectOption( lt.Code__c,lt.Name));                 }            return items;     }

}

 
 

Mavens Consulting is expanding rapidly and is looking to augment its development practice.  Dev 401 and 501 certifications are a plus.

 

Please email joe [at] mavensconsulting.com for more information.

  

http://www.mavensconsulting.com 

Message Edited by joe ferraro on 01-28-2010 08:13 AM
Message Edited by joe ferraro on 01-28-2010 08:13 AM

Does anybody know how I can populate a picklist from a trigger

 

My client whats the picklist to be dynamic

Is it possible to populate the picklist using Apex code from a class or a trigger?

 

I appears that it can be done using the Salesforce API but I can't find any examples where this can be done directly in Salesforce using the native apex code.

 

Thanks

 

Stephen

Is there a way I can add my pick list values from an apex code. Samething for controlling pick list fields?

 

Thank you.

  • October 23, 2009
  • Like
  • 0

I've managed to write code that inserts a value into a picklist field from my c# web application.  However, it is VERY clunky and I still can't figure out how to keep from losing some of the field properties.

 

First, it seems a little silly to have to programmatically recreate the entire picklist field just so I can update it with one new value in the picklistValues property.  Also, I have to do a describeSObject and then step through all the fields looking for the right field name.  Isn't there a way to just grab the metadata for a field directly?  I've seen code like the following, but....

Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.MyFieldName__c;

 ...but, I don't seem to have the Schema namespace/library at my disposal from the C# environment.  Is there ANY way to get DescribeFieldResult functionality in C#?

 

So I loop through the fields in the object, find the one I want, step through each of the picklist values and recreate them in a new array.  Then I add my new entry to the picklist values array and save it to the picklistValues property.  I can update the field and the new value does in fact show up in Salesforce.... but...

 

...another problem is that I end up losing the Picklist.Description and Picklist.Sorted properties because the Field object that I'm reading from doesn't have that information.

Well, enough words from me, here is the code.  This works, but you lose the Description and Sorted settings each time.  I post it in hopes that it helps someone and that perhaps someone can help us figure out the rest.

 

 

public void InsertPicklistValue(string objectName, string picklistFieldName, string valueToInsert) { try { // Load describe info for the object. DescribeSObjectResult descSObjectRslt = c_sfEnterprise.describeSObject(objectName); if (descSObjectRslt != null) { Field[] fields = descSObjectRslt.fields; foreach (Field field in fields) { if (field.name == picklistFieldName) { // Get the array of existing picklist entries. PicklistEntry[] picklistEntries = field.picklistValues; // We have to recreate the entire list of existing picklist values... List<PicklistValue> pVals = new List<PicklistValue>(); PicklistValue pVal; foreach (PicklistEntry picklistEntry in picklistEntries) { pVal = new PicklistValue(); pVal.@default = picklistEntry.defaultValue; if (picklistEntry.label != null) pVal.fullName = picklistEntry.label; else pVal.fullName = picklistEntry.value; pVals.Add(pVal); } // Add the NEW value... pVal = new PicklistValue(); pVal.fullName = valueToInsert; pVals.Add(pVal); // Now that we have the values, we need to save them to a new picklist. Picklist pList = new Picklist(); pList.picklistValues = pVals.ToArray(); //pList.sorted = how can we get this from the existing field? CustomField picklistField = new CustomField(); picklistField.fullName = objectName + "." + picklistFieldName; picklistField.label = field.label; picklistField.type = FieldType.Picklist; picklistField.picklist = pList; picklistField.inlineHelpText = field.inlineHelpText; //picklistField.description = how/where can we get this? // Update the existing picklist. UpdateMetadata updatedMetadata = new UpdateMetadata(); updatedMetadata.currentName = objectName + "." + picklistFieldName; updatedMetadata.metadata = picklistField; AsyncResult result = update(new UpdateMetadata[] { updatedMetadata })[0]; while (!result.done) { System.Threading.Thread.Sleep(result.secondsToWait * 1000); result = checkStatus(new string[] { result.id })[0]; } if (result.state == AsyncRequestState.Error) Console.WriteLine("Error {0}\n{1}", result.statusCode, result.message); else Console.WriteLine("Picklist updated successfully"); break; } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("\nFailed to get " + objectName + " description, error message was: \n " + ex); } }

 

 

Anyone?  Bueller?