• Lakshmi Prasanna 9
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 12
    Replies
hi,
 I write a plugin for ck editor.In this based on first selector second selector must be changed.this is not working properly can any body help me.

/**
 * The relatedToFields dialog definition.
 *
 * Created out of the CKEditor Plugin SDK:
 * http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1
 */

// Our dialog definition.
CKEDITOR.dialog.add( 'recipientsDialog', function( editor ) {
function addOption( combo, optionText, optionValue, documentObject, index )
  	{
 		combo = getSelect( combo );
 		var oOption;
  		if ( documentObject )
  			oOption = documentObject.createElement( "OPTION" );
  		else
  			oOption = document.createElement( "OPTION" );
  
  		if ( combo && oOption && oOption.getName() == 'option' )
  		{
  			if ( CKEDITOR.env.ie ) {
  				if ( !isNaN( parseInt( index, 10) ) )
  					combo.$.options.add( oOption.$, index );
  				else
  					combo.$.options.add( oOption.$ );
  
  				oOption.$.innerHTML = optionText.length > 0 ? optionText : '';
  				oOption.$.value     = optionValue;
  			}
  			else
  			{
  				if ( index !== null && index < combo.getChildCount() )
  					combo.getChild( index < 0 ? 0 : index ).insertBeforeMe( oOption );
  				else
  					combo.append( oOption );
  
  				oOption.setText( optionText.length > 0 ? optionText : '' );
  				oOption.setValue( optionValue );
  			}
  		}
  		else
  			return false;
  
  		return oOption;
  	}
  	function getSelect( obj )
 	{
 		if ( obj && obj.domId && obj.getInputElement().$ )				// Dialog element.
			return  obj.getInputElement();
 		else if ( obj && obj.$ )
 			return obj;
 		return false;
 	}
  
function removeAllOptions( combo )
  	{
 		combo = getSelect( combo );
  		while ( combo.getChild( 0 ) && combo.getChild( 0 ).remove() )
 		{ /*jsl:pass*/ }
 	}
	 var selectedObjectField = CKEDITOR.htmlTemplateRecipient;
	 var retObj = {

		// Basic properties of the dialog window: title, minimum size.
		title: 'Recipient Fields',
		minWidth: 400,
		minHeight: 200,
		
		// Dialog window contents definition.
		contents: [
			{
				// Definition of the Basic Settings dialog tab (page).
				id: 'insert-field',
				label: 'Recipient Fields',
				// The tab contents.
				elements: [
					{
						type: 'select',
						id: 'level1-fields',
						label: 'Select object',
						items: objectFields,
						onChange : function() {
							var dialog = this.getDialog(),
     				 		values = dialog.getContentElement( 'insert-field','level2-fields' ), 
      						//selectedSet = this.getValue();
		
		      		 function fetchListOfFields1(s) {
     				    alert( 'Current value11: '+s);

    				  optionsNames = new Array();
					 AllObjectsinOrg.getFldList(s,function(result, event) {
						if (event.status) {
							for(var i = 0; i< result.length; i++){
							var temp = new Array();
							temp.push(result[i]);
							optionsNames.push(temp);   
						}   
					}
					//CKEDITOR.dialog.add( 'relatedToFieldsDialog', this.path + 'dialogs/relatedToFields.js' );
					CKEDITOR.dialog.add( 'recipientsDialog',CKEDITOR.basePath + 'plugins/recipients/dialogs/recipients.js' 																);
					});
     			}
     			
     			fetchListOfFields1(this.getValue());
     			
     			 removeAllOptions( values );

   				 for ( var i = 0 ; i < optionsNames.length ; i++ )
   				 {
      				var oOption = addOption( values, optionsNames[ i ],
        			optionsNames[ i ], dialog.getParentEditor().document );
     				 if ( i == 0 )
     				 {
        				oOption.setAttribute( 'selected', 'selected' );
        				oOption.selected = true;
     				 }
    			}
  				}
  				
				
						
				},
				{
						type: 'select',
						id: 'level2-fields',
						label: 'Select field',
						 items :
  						[
    						[ '<none>', '' ]
  						]
						
				}
			  ]
			}
		],
		
		// This method is invoked once a user clicks the OK button, confirming the dialog.
		onOk: function() {
			
			// The context of this function is the dialog object itself.
			// http://docs.ckeditor.com/#!/api/CKEDITOR.dialog
			var dialog = this;

			editor.focus();
			editor.fire( 'saveSnapshot' );
			//editor.insertHtml( '{!User.'+dialog.getValueOf('insert-field','level1-fields')+'}' );
			editor.insertHtml('{!'+dialog.getValueOf('insert-field','level1-fields')+'.'+dialog.getValueOf('insert-field','level2-fields')+'}');
			editor.fire( 'saveSnapshot' );
	
		}
		
		
		
		
	};
	
	return retObj;
});



for ckeditor I added two plugins these to display picklists in dialog if selected one item in pick list based on that second pick list must be changed.please help me if any on know this
for ckeditor I added two plugins these to display picklists in dialog if selected one item in pick list based on that second pick list must be changed.please help me if any on know this
Hi,

My test classes are appearing in codecoverage box in developer console.
Previously I used to see only classes in codecoverage box , but now test classes are appearing. And showing Work_Test as 0%.
My Class is Work.
Test Class is Work_Test.
Both were appering in codecoverage box.
hi,
 I write a plugin for ck editor.In this based on first selector second selector must be changed.this is not working properly can any body help me.

/**
 * The relatedToFields dialog definition.
 *
 * Created out of the CKEditor Plugin SDK:
 * http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1
 */

// Our dialog definition.
CKEDITOR.dialog.add( 'recipientsDialog', function( editor ) {
function addOption( combo, optionText, optionValue, documentObject, index )
  	{
 		combo = getSelect( combo );
 		var oOption;
  		if ( documentObject )
  			oOption = documentObject.createElement( "OPTION" );
  		else
  			oOption = document.createElement( "OPTION" );
  
  		if ( combo && oOption && oOption.getName() == 'option' )
  		{
  			if ( CKEDITOR.env.ie ) {
  				if ( !isNaN( parseInt( index, 10) ) )
  					combo.$.options.add( oOption.$, index );
  				else
  					combo.$.options.add( oOption.$ );
  
  				oOption.$.innerHTML = optionText.length > 0 ? optionText : '';
  				oOption.$.value     = optionValue;
  			}
  			else
  			{
  				if ( index !== null && index < combo.getChildCount() )
  					combo.getChild( index < 0 ? 0 : index ).insertBeforeMe( oOption );
  				else
  					combo.append( oOption );
  
  				oOption.setText( optionText.length > 0 ? optionText : '' );
  				oOption.setValue( optionValue );
  			}
  		}
  		else
  			return false;
  
  		return oOption;
  	}
  	function getSelect( obj )
 	{
 		if ( obj && obj.domId && obj.getInputElement().$ )				// Dialog element.
			return  obj.getInputElement();
 		else if ( obj && obj.$ )
 			return obj;
 		return false;
 	}
  
function removeAllOptions( combo )
  	{
 		combo = getSelect( combo );
  		while ( combo.getChild( 0 ) && combo.getChild( 0 ).remove() )
 		{ /*jsl:pass*/ }
 	}
	 var selectedObjectField = CKEDITOR.htmlTemplateRecipient;
	 var retObj = {

		// Basic properties of the dialog window: title, minimum size.
		title: 'Recipient Fields',
		minWidth: 400,
		minHeight: 200,
		
		// Dialog window contents definition.
		contents: [
			{
				// Definition of the Basic Settings dialog tab (page).
				id: 'insert-field',
				label: 'Recipient Fields',
				// The tab contents.
				elements: [
					{
						type: 'select',
						id: 'level1-fields',
						label: 'Select object',
						items: objectFields,
						onChange : function() {
							var dialog = this.getDialog(),
     				 		values = dialog.getContentElement( 'insert-field','level2-fields' ), 
      						//selectedSet = this.getValue();
		
		      		 function fetchListOfFields1(s) {
     				    alert( 'Current value11: '+s);

    				  optionsNames = new Array();
					 AllObjectsinOrg.getFldList(s,function(result, event) {
						if (event.status) {
							for(var i = 0; i< result.length; i++){
							var temp = new Array();
							temp.push(result[i]);
							optionsNames.push(temp);   
						}   
					}
					//CKEDITOR.dialog.add( 'relatedToFieldsDialog', this.path + 'dialogs/relatedToFields.js' );
					CKEDITOR.dialog.add( 'recipientsDialog',CKEDITOR.basePath + 'plugins/recipients/dialogs/recipients.js' 																);
					});
     			}
     			
     			fetchListOfFields1(this.getValue());
     			
     			 removeAllOptions( values );

   				 for ( var i = 0 ; i < optionsNames.length ; i++ )
   				 {
      				var oOption = addOption( values, optionsNames[ i ],
        			optionsNames[ i ], dialog.getParentEditor().document );
     				 if ( i == 0 )
     				 {
        				oOption.setAttribute( 'selected', 'selected' );
        				oOption.selected = true;
     				 }
    			}
  				}
  				
				
						
				},
				{
						type: 'select',
						id: 'level2-fields',
						label: 'Select field',
						 items :
  						[
    						[ '<none>', '' ]
  						]
						
				}
			  ]
			}
		],
		
		// This method is invoked once a user clicks the OK button, confirming the dialog.
		onOk: function() {
			
			// The context of this function is the dialog object itself.
			// http://docs.ckeditor.com/#!/api/CKEDITOR.dialog
			var dialog = this;

			editor.focus();
			editor.fire( 'saveSnapshot' );
			//editor.insertHtml( '{!User.'+dialog.getValueOf('insert-field','level1-fields')+'}' );
			editor.insertHtml('{!'+dialog.getValueOf('insert-field','level1-fields')+'.'+dialog.getValueOf('insert-field','level2-fields')+'}');
			editor.fire( 'saveSnapshot' );
	
		}
		
		
		
		
	};
	
	return retObj;
});



please suggest,

controller----->

public class sampleCon {
   public string answer = '';
   public List<wrapperText> textWrap {get;set;} {textWrap = new List<wrapperText>();}


   public sampleCon(){
   for(Question__c ques : [Select id,Name,question__c,Option_1__c,Option_2__c from question__c] ) {
  
  
  
        textWrap.add(new wrapperText (ques , answer));
    system.debug('---------********----11----->'+textWrap);
    }
 
 
   }
 
 
 
     public string getAnswer() {    
         return answer;
    }
                 
    public void setAnswer(string answer) {
    {this.answer= answer;}
   } 
 
       public List<Question__c>getQuestion (){
  
     List<Question__c>listQuestion=[Select id,Name,question__c,Option_1__c,Option_2__c from question__c];
  
        return listQuestion;
     }        

   
    public PageReference test() {
        system.debug('------------------>'+answer);
        return null;
    }
    public List<Question__c>listQuestion{get;set;}
    /*
    public List<wrapperText> gettextWrap (){
    List<wrapperText> wrpTxt = new List<wrapperText>();
    for(Question__c ques : [Select id,Name,question_detail__c,Option_1__c,Option_2__c from question__c] ) {
  
    system.debug('-------------11----->'+wrpTxt);
  
        wrpTxt.add(new wrapperText (ques , answer));
  
    }
    return wrpTxt;
     }        
      */
}

vf page--->

<apex:page controller="sampleCon"  >
    <apex:form id="theForm">
  
      <apex:outputPanel id="str">
    
      </apex:outputPanel>
         <script>
                      
             function test1(id)
            {
                var theRadioButtonSet = document.getElementById(id);
                if (theRadioButtonSet.checked){
                    //alert('You Checked : '+theRadioButtonSet.value);
                    radiovalue(theRadioButtonSet.value);
              
                }            
             
            }
         </script>
     
         <apex:actionfunction name="radiovalue"  rerender="str">
       
         <apex:param name="radio" value="{!answer}"/>
       
         </apex:actionFunction>
       
       
      <!------- New PageBlock  Line ------------------------------------------> 
      
         <apex:pageblock >
         <apex:dataList id="Datalist1" value="{!textWrap}" var="Dlist" rows="2">
      
          <!-- <apex:outputField label="Question" value="{!Dlist.ques.question_detail__c}"/><br/> -->
          <apex:selectRadio id="SelectRadio1" onchange="test1(this.id);" value="{!Dlist.val}" >
      
               <!-- <apex:selectOption itemValue="india" itemLabel="India" />
               <apex:selectOption itemValue="ap" itemLabel="AP" /> -->
       
             <apex:selectoption itemlabel="{!Dlist.ques.Option_1__c}" itemvalue="{!Dlist.ques.Option_1__c}" />
             <br/>
             <apex:selectoption itemlabel="{!Dlist.ques.Option_2__c}" itemvalue="{!Dlist.ques.Option_2__c}" />
       
          </apex:selectRadio>
        
        
          <apex:outputPanel id="out">
          
           
                <p>You have selected:
                 <apex:outputText value="{!Dlist.val}"/></p>
                 <br/>
              
               
              </apex:outputPanel>
       
       
              
         <apex:commandButton value="Submit" action="{!test}" rerender="out" status="status" />
       
         </apex:dataList>
       
       
       
       
         </apex:pageBlock>
               
   </apex:form>
</apex:page>


  • June 05, 2014
  • Like
  • 0
Hi, 

I had three custom fields like available_casual_leaves__c,available_sick_leaves__c and days_off __c on leave_request__c object.
the default values of available_Casual_leaves__c is 20 and available_sick_leaves__c is 10. Now i have to update the default values in both available_casual_leaves__c and available_sick_leaves__c. for that i am writing

trigger availableLeavesTrigger on Leave_Request__c (before Update) {
    List<Leave_Request__c> lr= new List<Leave_Request__c>();
    List< Leave_Request__c> IdsForUpdate = new List< Leave_Request__c>();
    Leave_Request__c lqr=new Leave_Request__c();
    List<leave_request__c> leaveList=new LIST<leave_request__c>();   
    if(trigger.isUpdate)
    {
        for(Leave_Request__c l:trigger.new)
        {
            IdsForUpdate.add(l);
        }       
    }
    for(leave_request__C leave:[Select id,name, type_of_leave__c,Available_casual_leaves__c,
        Available_sick_leaves__c,  days_off__c from Leave_Request__c where id=:IdsForUpdate])
    {
       System.debug('isjfh 0 -- > '+leave);
        if(leave.type_of_leave__C=='casual leave')
        {
            System.debug('0 -- > '+leave);
            leave.available_casual_leaves__c=leave.available_casual_leaves__c-leave.days_off__c;
            System.debug('1 -- > '+leave.available_casual_leaves__c);
            leaveList.add(leave);          
        }
        else if(leave.type_of_leave__c=='sick leave')
        {
            leave.available_sick_leaves__c=leave.available_sick_leaves__c-leave.days_off__c;
            System.debug('2 -- > '+leave.available_sick_leaves__c);
            leaveList.add(leave);
        }
      }
      update leavelist;
  }

but i am not able to see any debug logs and ofcourse the values are not updating could any one tell me where i am going wroing
Hi,

I've had some help creating some Apex code which is supposed to do the following

Via Web-to-Lead I'm populating a field in our Lead Object called Promo_Code__c. Promo_Code__c has also been setup in our Campaign Object as an External ID. What I want to be able to do, is upon creation/update of a Lead is to cross reference the Promo_Code__c with the relevant Campaign and link the Lead to that Campaign (using Promo_Code__c External ID).

The code below saves okay, and works correctly if I create a Lead Record, save it, then edit it and include the Promo_code__c. It doesn't work correctly however if I create a brand new Lead and input the Promo_Code__c before saving. If I do this, the error code is as follows:

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger Update_Campaign caused an unexpected exception, contact your administrator: Update_Campaign: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, This entity is already a member of this campaign: []: Trigger.Update_Campaign: line 32, column 1".

The Lead Trigger is as follows:

trigger Update_Campaign on Lead (after insert, before update) {

  List<ID> LeadIds = new List<ID>();
  List<String> prStr = new List<String>();
  List<CampaignMember> newList = new List<CampaignMember>();

for(Lead LD: Trigger.new){
    if(LD.Promo_Code__c!=null)
    {
        prStr.add(LD.Promo_Code__c); //Assuming Promo_Code__c is of Text type;
    }
}

 
Map<String,Id> cmMap = new Map<String,ID>();

for(Campaign cm1 :[select id,Promo_Code__c from Campaign where Promo_Code__c IN: prStr])
{
    cmMap.put(cm1.Promo_Code__c,cm1.Id);
}

for(Lead LD: Trigger.new){
    if(LD.Promo_Code__c!=null)
    {
        CampaignMember cm = new CampaignMember(CampaignId=cmMap.get(LD.Promo_Code__c),LeadId=Ld.id);
        newList.add(cm);
    }
}

if(newList.size()>0)
{
    insert newList;
}


Any help would be Much Appreciated!!