function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KayalKayal 

Custom Picklist field

Have created a Activity Custom Field of Datatype 'Picklist' and i'm using this Custom Field in 'Task' activity. Is it possible to set values(dynamic) to this picklist from c# when a task is created? I'm using Partner wsdl in my application. Explaining this in detail would be appreciated.

 

-Kayal

SrikanthKuruvaSrikanthKuruva

say the picklist values are 

A, B, C

when the task is created you want assign a new value 'D' to the field on the record. is this what you are looking for?

Or do you want to add the value 'D' to the picklist values (metadata) of the custom field?

 

KayalKayal

Hi Srikantha,

Thanks for your reply.
Need to assign new value(s) to the picklist on the task record. I'm creating a task via C# code(using partner wsdl) so i want to set the new picklist value(s) while creating my task in c# code. But the picklist value will change for each task.
Say, for Task1 the picklist values are A,B,C,Dand for the Task2 the picklist values can be C,E,F
Is this possible to set the picklist field values which may change dinamically? 

SrikanthKuruvaSrikanthKuruva

for showing different picklist values for different tasks on the aspx page is not a problem.

For assigning the value you dont have to do any thing extra in aspx.cs to assign the selected value to the picklist field. just do

 

task1.picklist_field__c = DropDownList1.SelectedValue.ToString();

 

and done. please let me know if you have any questions.

KayalKayal

This is how i'm setting task "Status" field value as "In Progress":
sObject newTask = new sObject();

sObject[] tasks = new sObject[1];

System.Xml.XmlElement[] taskElement = new System.Xml.XmlElement[2];

System.Xml.XmlDocument taskDocument = new System.Xml.XmlDocument();


xmlElement[0] = xmlDocument.CreateElement("Status");

xmlElement[0].InnerText = "In Progress";


xmlElement[1] = xmlDocument.CreateElement("Contact_ID__c"); //setting a custom field value(normal text field)

xmlElement[1].InnerText = "1234567890";


newTask.type = Constants.TaskLabel;

newTask.Any = taskElement;

tasks[0] = newTask;

//Invoke the Create Operation

sforceService.create(tasks);


This would create a task with "Status" field value set to "In Progress" and a custom field named "Contact_ID__c" would be set to "1234567890" value.

Is it possible to set value of my custom picklist field value like this? Is there anything to be processed with "describeSObjectResults " or "PicklistEntry[]"?

SrikanthKuruvaSrikanthKuruva

yes you can set the value of your custom picklist in the same fashion. You dont have to do anything extra like "DescribeSObjectResults " or "PicklistEntry[]"

KayalKayal

I was able to set dynamic values for the picklist like:

taskElement[0] = taskDocument.CreateElement("MyPickList__c");           

taskElement[0].InnerText = "Test1"; 

This would set "Test1" value for the picklist field on my Task record.
Is it possible to set multiple values (i.e.) i want the picklist dropdownvalues as "Test1", "Test2", "Test3". 
 

SrikanthKuruvaSrikanthKuruva

if you want to assign multiple values to the picklist field

1.) the picklist field should be multi select picklist field

2.) In the code you need to do the following

taskElement[0].InnerText = "Test1; Test2; Test3"; //values should be semicolon seperated

 

please let me know if i misunderstood your point.

KayalKayal

but however its setting the values in the "Chosen" list column when the task is created. Is there any way to set all the values to the "Available" column?

SuperfellSuperfell

Available picklist entries can't be set on a record by record basis, they can vary by record type and/or page layout only.