• Pramod Gowda
  • 35 Points
  • Member since 2014

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
  • 12

In case object i created one formula field. in this formula field i want to display case owner locale based on this soql query 
" select id,localesidkey from user where id in(select ownerid from case) "

  • May 20, 2016
  • Like
  • 1
Hai hall
 i got only 88% code only

i wrote my trigger code & testclass below  please help me.
Red mark show only a.name.adderror in code coverage.
trigger code:
trigger validationoncontact on Account (before insert) {
    set<string>setv=new set<string>();
       // soql query to return the no of records.
    list<contact>con=[select id,lastname from contact];
       // if size of the records is more than 0 ,then proceed our logic
        // Return the number of records one by one
       for(contact c:con)
           // add a contact lastname to setv  to comapre the values. 
    // "trigger.new" which holds the list of new records, whatever trying to insert the records. 
    for(account a:trigger.new){
       // it returns a true if the string contains specfied character otherwise it return false.
            a.name.adderror('Duplicate : Already contact is Existed with this name');

test class 
public class testclassforvalidationcontact {
    static void testme(){
     contact c=new contact(lastname='arjun');
        insert c;
        string names='';
        list<contact>cc=[select id,lastname from contact where id=:c.id];
        for(contact c1:cc){
        account a1=new account(name='mallik');
            insert a1;
            system.assertnotEquals(a1.name, names);
        }catch(exception e){
            System.debug('should not be created duplicate record');


HI All, 

I am hoping you can help me. I am very new to VF and Apex and been using different resources on line and i am now stuck and dont know how to proceed. i am getting the following error 'unexpected token: '{' at line 39 column 26' when trying to save the class

Aim : The user should go to the Sales & Marketing Object, click on a related list, this should then open up a VF page. The VF page should show all of the records from the Materials Object. The user should select the records and the Quanity value, upon save this should then map back to  Sales & Marketing Object

I have created the following three objects
Materials = 01I20000000rV5S
Materials Junction = 01I20000000rV6B
Sales and Marketing = 01I20000000rV6V

This is the class that i have produced  

public with sharing class test
    public List<Materials__c> Materials {get;set;} //global variables
    public List<materialWrapper> materialWrapperList {get;set;} //use this list on vf page and not Materials

    public test()
        Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10];
        for(Materials__c obj : Materials){
            materialWrapper tempObj= new materialWrapper();
            tempObj.recordId = obj.id;
            tempObj.name = obj.name;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.select = false;

    //save method
    public void save()
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        for(materialWrapper obj : materialWrapperList){
            if(obj.select == true){
                Materials_Junction__c temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = '01I20000000rV6V';
                temp.Materials= obj.recordId;
                temp.quantity = obj.quantity; 
        insert recordToInsert;
    public materialWrapper{
        string recordId {get; set;}
        string name {get; set;}
        string product {get; set;}
        string item {get; set;}
        string quantity {get; set;}
        boolean select {get; set;}
        public void materialWrapper(){
            recordId = '';
            name = '';
            product = '';
            item = '';
            quantity = '';
            select = false;

Materials Junction Fields
User-added image

Materials Object Fields 
User-added image

Hoping you can help 

Looking forward to your response 

Many thanks 
Hi All,

I have one master table"Question" and child table "Option" now here i want to show questions and its related options( with radio button) in vf page and get option value for respective question. I am able to fetch question and option on vf page but didnt able to pass option value to apex class.Pls Help..

<apex:page Tabstyle="Account" controller="WOS_WrapperExample">
 <apex:form >
            <apex:repeat value="{!Quest_OptionList}" var="a">
              <tr> <td>{!a.acc.Name}</td> </tr>
             <apex:repeat value="{!a.acc.Option__r}" var="o">
                 <tr>  <td><apex:inputCheckbox value="{!a.selected}" id="checkedone" /></td>                 
                         <td id="theIDD" >{!o.name}</td>                 

Apex Class :
public class WOS_WrapperExample
public List<QuestionOptionWrap> Quest_OptionList {get;set;}
public List<QuestionData__c> selectedQuestions {get;set;}
  public WOS_WrapperExample() {
  Quest_OptionList = new list<QuestionOptionWrap>();
  selectedQuestions = new list<QuestionData__c>();
   for(QuestionData__c a : [select Id, Name,(select name from Option__r) from QuestionData__c limit 10])
      Quest_OptionList .add(new QuestionOptionWrap(a));  
    public PageReference Selectedacc()
        for(QuestionOptionWrap accwrapper : Quest_OptionList )
        if(accwrapper.selected == true)
        return null;

    public class QuestionOptionWrap
        public QuestionData__c acc{get; set;} 
        public String optionOne{get; set;}
        public QuestionOptionWrap(QuestionData__c a) // Constructor of wrapper class
            acc = a;
            selected = false;    
<script type="text/javascript">
    function Disablefilter(var1){

   var selectreporttype = document.getElementById('{!$Component.fid:pgBlckId:pgsec:pgsecitem:reportSelList}');
        var selreport = selectreporttype.options[selectreporttype.selectedIndex].value;
       var selectreporttype1 = document.getElementById('{!$Component.fid:pgBlckId:pgsec:pgsecitem:MonthSelList}');   

      if(selreport =='Booked Order MTD')
       alert('var1')//entering into if condition but the next line is not working for hidden


  <apex:selectList id="reportSelList" size="1" value="{!selectedreports}" style=" padding: 2px 4px; margin: 4px 2px;"  onchange="Disablefilter('{!$Component.myid}');" >
   <apex:outputPanel id="myid" >   
        <apex:selectList id="MonthSelList" size="1"  title="List of Months in year" value="{!selectedMonth}"  style=" padding: 2px 4px; margin: 4px 2px;" rendered="{!if((selectedreports =='Booked Order YTD' && agingError=true)||(selectedreports =='Revenue YTD' && disablefilter1=true),True,False)}">
                <apex:selectOption itemvalue="Months" itemLabel="Select a Month" />
                <apex:selectOption itemvalue="1" itemLabel="Completed"/>
                <apex:selectOption itemvalue="2" itemLabel="Open"/>
I have a detail page button on my Opportunity page. I want to use onclick Javascript to capture two date fields called Start Date and End Date. I am able to input the dates using prompt in javascript. Is it possible to insert those dates into the same opportunity record?
I have a requirement. Contact related to Task, I need to pull his functional role ( custom field) on Activity page layout. So whenever I create or edit an activity and relate with ant contact so his/her functional role should populate automatic.

Please help! How can I achieve it? I tried formula field but unable to get. I tried through trigger but it is not working nighter on new task nor while I update the task.
Please find below code:
trigger updatefunctionalrole on Task (before insert, before update) {

Map<ID,String> confunrole = new Map<ID,String>();
List<Task> conTasks = new List<Task>();

for (Task e : trigger.new) {

    if (e.whoID!= null && (String.valueOf(e.whoID)).startsWith('003'))  {

        if (trigger.isInsert || (trigger.isUpdate && e.WhoID != trigger.oldMap.get(e.id).WhoID)) {

for (contact con : [SELECT Functional_Role__c FROM contact WHERE ID IN :confunrole.keySet()]) {
// Update the contact functional role field on the Task with the relevant value
for (Task e : trigger.new) {
    e.functional_role__c = confunrole.get(e.whoID);
Kindly let me me know where I am doing wrong.

In case object i created one formula field. in this formula field i want to display case owner locale based on this soql query 
" select id,localesidkey from user where id in(select ownerid from case) "

  • May 20, 2016
  • Like
  • 1
H iall

Aware this is a bit of an odd request but I was wondering if anyone can help.  I use salesforc ein a primary school so we can't afford the developer costs associated with normal salesforce use case development but was hoping that someone might be able to help me do something.  Basically I (a certified admin) need to create someway of scanning information from a template which lists students in a class and denotes whether they are present or not (morning attendance).  The sheets list all the studenmts names and their student ID along with a box filled in for absent or present.  If its left black they are present.  This sheet is fully typed and printed but the penciling in denotes if theres an absense.  Basically I want to find a way to scan these attendance sheets into salesforce and have a record created for each student to record their attendance situation for the day.  The sheet is the same each day for each class.  it just needs to record the date, student idf and the attendance for each student once a day. 

I am aware there is a 3rd party system that can do this but its so expensive per year.  I see that there are APIs that can help with this and set areas for partial recognition areas but I have no idea how to do this at all.  I was looking at http://ocrsdk.com/documentation/apireference/ and http://www.online-code.net/ocr.html.

If anyone thinks they can help or make this process kind of idiot proof for me I'd really appreciate it.  I know what I need to do once the data is collected in salesforce but its just getting it from the sheet into tthe system.  Its seriously just for kids attednance to be recorded so we can find out where they are or why they are not somewhere as quickly as possible and maki ng alerts using workflows etc.  The impact of this would be huge.  any help or expertise much appreciated.  I do believe for someone who knows what they are doing this might not be super hard.