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
bujjibujji 

Task 'Related To' list re order

Hi,

 

I am creating a task from the vf page, is it possible to re-order the list in 'Related To' field. Currently 'Account' is the default value. I want Opportunity as the default/first value in the list.

 

how to do it.

 

i tried Task mytask = new Task(what = 'Opportunity');   but  i am getting error saying what is not writable field.

 

Thanks,

Bujji

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

Your insert statement is wrong for inserting related to field in Task.

 

It shoulb be WhatID, you just mentioned what while inserting.

 

Try the following,

 

Opportunity opp = new Opportunity(name='Opp 1', stagename='Prospecting', closedate=Date.today()+10);

insert opp; //This opp id is going to be related to in task

 

Task mytask = new Task(whatid =opp.id);//here you mentioned wrongly

 

Don't forget to give Kudos and mark this answer as a Solution if this works out.

bujjibujji
the code i have written is not to insert but to show the opportunity in 'Related To' field. I question is, is it possible to re-order the 'Related To' field list value.......

Thanks,
Bujji
goabhigogoabhigo

Hi Bujji,

 

This is probably not possible if you are using the standard field in VF page. You can use a custom select list and populate all the possible values of "Related To" into this. WhatId is really matters, not What, while saving. How you have used VF page for creating new task? Is it by overriding the standard New button?

bujjibujji
Oh, yes i am using salesforce standard field called Related To. I am not overriding the task new button. It is a form in which the user has to enter the values and click on the save button.

in the controller my code is Task mytask = new Task();

thanks,
Bujji