• Nikhil Verma 6
  • 125 Points
  • Member since 2017

  • Chatter
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 39
I am trying to create a trigger that will auto populate a date field when a picklist value is selected. I'm trying to achieve this without creating another custom object. 

Ex. PIcklist Values: Test, Demo, Draft

If Test; then date value = 12/1/2018
If Demo, then date value = 11/1/2018
If Draft then, date value = 10/1/2018

 I am using map to assing ownerid from account it giving below eror message please suggest me how to fix

 Error: Compile Error: Method does not exist or incorrect signature: void get(Id) from the type Map<Account,Id> at line 68 column 47
public class CtapAssessmentTriggerUtils { 
    public static void processInsert(List<CTAP_Assessment__c> newLst) {
        Set<String> emailSet = new Set<String>();
        Set<String> partnerSet = new Set<String>();
        Lead l = new lead();
        Map<String, Id> mapEmailToConId = new Map<String, Id>();
        Map<String, Id> mapEmailToLeadId = new Map<String, Id>();
        List<Lead> newLeadLst = new List<Lead>();
        Map<String, CTAP_Assessment__c> newLeadforCtapMap = new Map<String, CTAP_Assessment__c> ();
        // collect emails in a set
        for(CTAP_Assessment__c ctap : newLst) {
            system.debug('ctap.Contact_Email__c ' + ctap.Contact_Email__c);
        // removing nulls
        system.debug('emailSet '  + emailSet);
        if(!emailSet.isEmpty()) {
            for(Contact objCon : [select id,email from contact where email IN :emailSet]){
                mapEmailToConId.put(objCon.Email, objCon.Id);
            for(Lead objLead: [select id,email from Lead where email IN :emailSet]){
                mapEmailToLeadId.put(objLead.Email, objLead.Id);
         Account[] partnerActs = [select ownerid,owner.name from account where id = :partnerSet limit 1]; 
         Map<Account, ID> PartnerActMap = new Map<Account, ID>();
         for(Account ObjPartnerAct : [select id,owner.name,ownerid from account where id in :partnerSet]){
        // asssign based on map key match with email
        for(CTAP_Assessment__c ctap : newLst){
            if( mapEmailToConId.get(ctap.Contact_Email__c) != null){
              ctap.Contact__c = mapEmailToConId.get(ctap.Contact_Email__c);
              ctap.Lead__c = null;
             }else if ( mapEmailToLeadId.get(ctap.Contact_Email__c) != null) {
              ctap.Lead__c = mapEmailToLeadId.get(ctap.Contact_Email__c);
              ctap.Contact__c = null;
              else {         
                  // Create a new lead         
                  l.Company = ctap.End_Customer_Name__c;
                  l.FirstName = ctap.Contact_First_Name__c; 
                  l.LastName = ctap.Contact_Last_Name__c; 
                  l.Email = ctap.Contact_Email__c;
                  l.Phone = ctap.Phone__c;
                  l.Title = ctap.Title__c;
                  l.Industry = ctap.Industry__c;
                  l.LeadSource = ctap.Lead_Source__c;
                  l.Country = ctap.End_Customer_Country__c;
                  l.State = ctap.state__c;
                  l.Postalcode = ctap.postalcode__c;
                  l.Employee_Size__c = ctap.Employee_Size__c;   
                  if(ctap.Partner_Account__c !=  null && ( ctap.End_Customer_Country__c != 'USA') ){ //Here it checks only for country USA
                    l.Ownerid = PartnerActMap.get(ctap.Partner_Account__c);   
                 if(ctap.Contact_Email__c <> null && 
                    ctap.End_Customer_Country__c <> null &&
                    ctap.End_Customer_Name__c <> null &&
                    ctap.Contact_First_Name__c <> null ) {                                                    
                 newLeadforCtapMap.put(ctap.Contact_Email__c, ctap);
           if ( !newLeadLst.isEmpty() ){
                insert newLeadLst;
                      /* Run lead assignment rule.
                         Database.DMLOptions dmo = new Database.DMLOptions();
                         dmo.assignmentRuleHeader.useDefaultRule = true;
                         Database.update(newLeadLst, dmo); 
                 for(Lead lead : newLeadLst){
                    CTAP_Assessment__c ctap = newLeadforCtapMap.get(lead.Email);
                    ctap.Lead__c = lead.id; //Assign new lead to lead
    public static void processUpdate(Map<id,CTAP_Assessment__c> newMap, Map<id,CTAP_Assessment__c> oldMap) {
        List<CTAP_Assessment__c> changedLst = new List<CTAP_Assessment__c>();
        for(CTAP_Assessment__c ctap : newMap.values()){
            CTAP_Assessment__c oldCtap = oldMap.get(ctap.id);
            //Compare with if condiction 
           // if(ctap.Contact_Email__c != oldCtap.Contact_Email__c) {// compare other required fields here.
              if(ctap.Contact_Email__c != null){
Hi All,
I have a scenario where I need to execute a SOQL query inside of "For" loop.
When I execute this, the query returns 4 results. But, the object "PendingApprovals" contains only last record. 
public list<Knowledge__kav> PendingApprovals {get;set;}
string kbid;                    
             for(Knowledge__kav KnwObj:knowledgeList)
                      kbid= KnwObj.Id;
                      PendingApprovals = [Select Id ,Title, 
                      Summary__c, LastModifiedDate , 
                                                     CreatedById ,PublishStatus                         
                                                       from Knowledge__kav 
                                                     where Id  = :kbId];
I have 4 values of kbId. So, PendingApprovals should contain 4 items. But, it returns only one(last value). 
How do i loop through 4 values of kbid? 

Also, please suggest if SOQL query can be executed inside of for loop like I am doing. 
Any other better way to achieve this? 

So I have a trigger that I'm trying to write to update a value on a custom object when it is updated or created. The value should only be updated if the user does not have a certain permission set assigned to them. I have been trying to figure out how to check the user's ID against a list that contains the ids for the users that were assigned to that permision set, but I am fairly new to coding and googling is not working out. Maybe one of you can help? Here is my terrible code that isn't compiling: 
trigger UpdatePermissions on box__FRUP__c (before insert, before update) {
    //Create list of Easement Managers based on the Permission Set: 'Easement Management Fields'.
    List<PermissionSetAssignment> EasementManagers = [Select AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId = '0PS0c000000Pi9z'];
    //Check User ID against Assignee ID. If not in list, change FRUP permission to  'Read' instead of 'Read/Write'.
   { for (box__FRUP__c frup : Trigger.New) {
        if (frup.box__Salesforce_User__r.ID IN EasementManagers)
			//do nothing
        } else {
            frup.box__Permission__c = 'Read';

I need help to create a task based on Opportunity Field.
Let's say I have a picklist field in Opportunity called 'Type' with Values A, B.

 If value 'A' is selected then you must check for Synced Quote in that Opportunity related list. In the synced Quote, if the Status field is 'Rejected' then we must create 2 Tasks in the Opportunity Record with the subject line 'Task Subject 1' and 'Task Subject 2'.

I have a custom picklist field in the Task called 'Task Value' with values X, Y. 

So Tasks must be created as
Task 1:
Subject Line: Task Subject 1
Task Value: X

Task 2:
Subject Line: Task Subject 2
Task Value: Y

These 2 tasks must be displayed on the opportunity related list 'Open Activities'.
  • November 22, 2017
  • Like
  • 0
I have a requirement to create an approve button in the products(related list under opportunity). When the user selects the products and click on approve button, then for each product line item an asset record should be create on approval. Can anyone suggest some samples please.
I am new to Salesforce. I am trying to get detail to show when I click the link. I check to see if parameters are passed and  no values are updated can someone tell me what is wrong.  thanks

<apex:page standardController="Account" recordSetVar="acts" sidebar="False" >
   <apex:form >
        <apex:pageBlock title="Accounts" > 
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!acts}" var="a">
                    <apex:column >
                        <apex:commandLink value="{!a.name}"  reRender="relView"/>
                        <apex:param name="AccountID" value="{!a.ID}"/>
                        <apex:param name="Name" value="{!a.Name}"/>
                    <apex:column value="{!a.ID}" />
                    <apex:column value="{!a.Industry}" />
                <apex:pageBlock title="Account Detail" ID="relView">
Hello all,

I am having some trouble with an Apex Trigger test class I'm writing. I am using a developer sandbox and am getting the following error:
System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: a0D6A0000015UKi: []

What I am trying to do is update a Lookup field that looks up to a Rate Sheet based on certain criteria. (Rate_Sheet__c = API Name)

I wrote the trigger and had no errors that I could see but when writing the test class it kept giving me the Insufficient Access error. Not really sure what the problem is. Under sharing settings, my org wide defaults gives public read/write access to all objects needed.

Please see the following Apex Trigger and Test Class code:
trigger UpdateRatesheetLookup on Quote (before insert, before update) {

    for (Quote quo : Trigger.new) {
        if (quo.TotalPrice < 3000 && quo.Buyout_Type__c == 'FMV') {
            // Sets Rate Sheet Lookup
            quo.Rate_Sheet__c = 'a0D6A0000015UKi';
        } else if (quo.TotalPrice < 10000 && quo.Buyout_Type__c == 'FMV') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKj';
        } else if (quo.TotalPrice >= 10000 && quo.Buyout_Type__c == 'FMV') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKk';
        } else if (quo.TotalPrice < 3000 && quo.Buyout_Type__c == 'Promo FMV') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKl';
        } else if (quo.TotalPrice < 10000 && quo.Buyout_Type__c == 'Promo FMV') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKm';
        } else if (quo.TotalPrice >= 10000 && quo.Buyout_Type__c == 'Promo FMV') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKn';
        } else if (quo.TotalPrice < 3000 && quo.Buyout_Type__c == '$1-out') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKo';
        } else if (quo.TotalPrice < 10000 && quo.Buyout_Type__c == '$1-out') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKp';
        } else if (quo.TotalPrice >= 10000 && quo.Buyout_Type__c == '$1-out') {
            quo.Rate_Sheet__c = 'a0D6A0000015UKq';
        } else {
            quo.Rate_Sheet__c = Null;

// Problem is happening at insertion of the myQuote instance.
private class UpdateRateSheetLookupTest {
    @isTest static void updateQuote() {
        // Create an Account & Set Required Fields
        Account myAccount = new Account();
        myAccount.Name    = 'Sample Account';
        insert myAccount;
        // Create an Opportunity on the Account & Set Required Fields
        Opportunity myOpportunity = new Opportunity();
        myOpportunity.Name        = 'Sample Opportunity';
        myOpportunity.CloseDate   = Date.today();
        myOpportunity.StageName   = 'Proposal';
        myOpportunity.AccountId   = myAccount.Id; // Relates to id of account above.
        insert myOpportunity;
        // Fire the UpdateRatesheetLookup Trigger
        // Create a Quote associated with Opportunity & Set Required Fields
        Quote myQuote          = new Quote();
        myQuote.Name           = 'Sample';
        myQuote.OpportunityId  = myOpportunity.Id; // Relates to id of opportunity above.
        //myQuote.TotalPrice   = 2500;
        myQuote.Buyout_Type__c = 'FMV';
       	insert myQuote; // FLAG: PROBLEM HERE
        // Update the Quote
        myQuote.Description = 'Test';
       	update myQuote;

Any help with this would be greatly appreciated. 
Thanks in advance!
I am trying to create a trigger that will auto populate a date field when a picklist value is selected. I'm trying to achieve this without creating another custom object. 

Ex. PIcklist Values: Test, Demo, Draft

If Test; then date value = 12/1/2018
If Demo, then date value = 11/1/2018
If Draft then, date value = 10/1/2018
I have created a form in the Salesforce Support console that updates knowledge fields when you push the save button. This all works perfectly. However after you hit save the visualforce page changes to the Case Record in the small area the form was. I would like it to stay on the form and not change after the save button is push. I am not sure how I do this.

<apex:page showHeader="false" standardStylesheets="false" standardController="Case" pageStyle="Left"> <style> p.small { line-height: 0.5; } </style> <font face = "Arial" align="left" style="font-size:11px" color="454545"> <table style="width:100%"> <apex:form > <apex:pageBlock > <apex:pageBlockSection columns="1"> <apex:commandButton action="{!save}" value="Save" id="theButton"/> <apex:inputField value="{!Case.Steps__c}"/> <apex:inputField value="{!Case.Environment__c}"/> <apex:inputField value="{!Case.Additional_Information__c}"/> <apex:inputField value="{!Case.Answer__c}"/> </apex:pageblocksection> </apex:pageBlock> </apex:form> </table> </font> </apex:page>
Hi All,

I have created a visualforce page and overriden the standard delete action button with that visualforce page. when I click on the delete button before launching my page content, I'm seeing the popup saying "Are you sure?" . Is there any way that we can remove this standard action on load of my visualforce page?

I do not want to see the standard delete confimation popup message when delete button is being clicked.
Delete popup

Is there a way to generate a link to an image I can place in the <img src="" >  of a html document?

This document will be hosted on one of our websites. currently I am not able to get a link that I can paste in to an <IMG> tag 

NOTE: I am using the API to fetch data from Salesforce. this is why I would like there to be a field in every product that will contain an valid src link to the products image. 
Why did the following not work for the validation rule ?  It gave an error with no real explanation.

  NOT isBlank(AccountID),
   NOT CONTAINS(MailingPostalCode, Account.ShippingPostalCode)
In my code
trigger ContactRole on Application__c (before update) {

// Get the time between the last aTeam and bTeam
                DateTime lastUWCreated = lastCCUW.Created_Date__c;
                System.debug('lastUWCreated ' + lastUWCreated);
                DateTime lastAmTeamCreated = lastCCRiskAndChecked.Created_Date__c;
                System.debug('lastAmTeamCreated ' + lastAmTeamCreated);
                Double workingHours = calculateWorkingHours(lastUWCreated, lastAmTeamCreated);
                System.debug('workingHours ' + workingHours);
                Id ccAppId = lastAmTeamCreated.Id;
                List<Application__c> ccAppList = [SELECT CalculatedWorkingHours__c from Application__c where id = :ccAppId];
                Application__c appRecord = ccAppList.get(0);
                appRecord.CalculatedWorkingHours__c = workingHours;
                System.debug('appRecord.CalculatedWorkingHours__c ' + appRecord.CalculatedWorkingHours__c);

I'm using the before update trigger in order to populate the calculated working hours into a custom field called "CalculatedWorkingHours__c".

I can see in the debug log that the  "CalculatedWorkingHours__c" field is updated
USER_DEBUG [184]|DEBUG|workingHours 17.5

USER_DEBUG [194]|DEBUG|ccAppRecord.CalculatedWorkingHours__c 17.5
but on a record level the field remains blank

Please advise what can be the issue and why the field is not populated in the record?
Hello everyone,

I saw in this post : https://success.salesforce.com/ideaView?id=087300000007qCj
that the Line Item Service Date should be equal to the Start Date of a LineItemSchedule. However, for us, the ServiceDate (called "Date" within the Opportunity Product) is always empty and I don't know why. I would like to equal the Start Date of the LineItemSchedule as I said before.

Thank you
Hi guys, I just took over as the Org system admin. I am trying to edit a thank you letter that was inserted by our previous IT guy, it is basically a letter that is generated by the system when prompted by the user, once a donation is recorded, the user can press "preview letter" or "email letter". I would like to keep the same letter but use a different background (we have a new logo), and have no clue on how to do so. When I go to setup, the letter object is a bunch of code, that I do not really know how to modify.

Hello All, 

Can anyone tell me, how to use the Column Function in apex class ?

I have no idea how that works. 

Thank you all in advance.
Hello Guys,  In my scan report, I am getting the issue : Query: Bulkify Apex Methods Using Collections In Methods
I have written some nested for loops but no any DML and Query in any loop, why I am getting this error,
Here is the code snipt.

Please HELP
if(!rule_wise_records.isEmpty() && !rule_wise_Users.isEmpty()){
            System.debug('I am in Maps');
            list<string> subscridersId = new list<string> ();
            list<sObject> recordsToFollow2 = new list<sObject> ();
            System.debug('Rule Wise Records ' +json.serialize(rule_wise_records));  //This map Contains key and List Of Sobjects
            System.debug('Rule Wise rule_wise_Users ' +json.serialize(rule_wise_Users)); //This map Contains key and List Of Strings
            for(id rule : rule_wise_records.keySet()){
                System.debug('Key =====>' +rule);
                    recordsToFollow2 = (list<sObject>) rule_wise_records.get(rule);
                System.debug('I am in Maps Records '+recordsToFollow2);
                    subscridersId = rule_wise_Users.get(rule);
                System.debug('I am in Maps Users '+subscridersId);
                Set < String > toRemoveDuplicates = new Set < String > ();
                if(subscridersId!=null && subscridersId.size()>0)
                List < String > uniqueId = new List < String > ();
                string parentId;
                string uesrIds ='';
                for (sObject eachRec: recordsToFollow2) {
                    parentId = ((ID) eachRec.get('id')); //.substring(0,15);
                    //for (integer i = 0; i < uniqueId.size(); i++) {
                    for (String sId : uniqueId) {
                        EntitySubscription e = new EntitySubscription();
                        uesrIds = sId;
                        string key = parentId.substring(0, 15) + '@' + uesrIds.substring(0, 15);
                        if (Record_Wise_SubscriberId.ContainsKey(key) == false) { 
                            e.ParentId = parentId;
                            e.SubscriberId = sId;//userIds[i];
                            System.debug('I am in Maps ES_ListToinsert '+ES_ListToinsert);
                                map_SubEntityWiseFollowRules.put(key, rule);

Hi All,

I have a visualforce page to render as PDF. This page has few images with total size as 5MB but it throws view state limit exception. The salesforce documention says "The maximum total size of all imagesincluded in a generated PDF is 30 MB". I don't have any controller variable(dynamic values) to show on the page. it all has static text, CSS and images.

Not sure why this view state limit hits given that the salesforce allows total image size as 30MB and imanges to show in my case is just 5MB. Any help or pointer on this would be greatly appreciated.

  • November 08, 2017
  • Like
  • 0

I need help on the following requirement , 

1) I have a custom "Clone" button on a custom object called "Proposal" , on click of it it will clone all fields on proposal in addition to it , it will also clone 2 related list values such as contract payment , business type which is working fine

my requirement is in addition to that 2 related list i want to clone the Notes and attachment  and files also along with it. The file uploaded should also be carried on clicking clone button also with the notes.

Please help me how to achieve it.


var query = "SELECT Id,Opportunity__r.StageName,Forecast_MCA_Revenue__c	,Reason_for_Discount__c ,Proposal_Start_Date__c,Proposal_End_Date__c,Name,Account__c,Commercial_TC__c,RecordTypeId,Domestic_Annual_Share__c,Charter_Price__c,International_Annual_Share__c,Legal_TC__c,Opportunity__c,Contact__c,Qantas_Annual_Expenditure__c,Qantas_Club_Join_Discount_Offer__c,Status__c,Valid_From_Date__c,Valid_To_Date__c,Standard__c,Deal_Type__c,MCA_Routes_Annual_Share__c,Agent_Name__c,Agent_Fax__c,Agent_Email__c,Agent_Address__c,Frequent_Flyer_Status_Upgrade__c,Frequent_Flyer_Status_Upgrade_Offer__c,Qantas_Club_Discount__c,Qantas_Club_Discount_Offer__c,TMC_Code__c,Travel_Fund__c,Travel_Fund_Amount__c,Type__c,NAM_Approved1__c,Pricing_Approved1__c,DO_Approved__c,Approval_Required_Others__c,Leadership_Rejected__c,TeamLead_Approved__c,SBD_Approved__c,QIS_Approved__c,QIS_Rejected__c,Additional_Change_Details__c,(SELECT Id, Route_Origin__c,Route_Destination__c,FareStructure__c, Comment__c, Discount__c, Discount_Threshold_AM__c, Discount_Threshold_NAM__c,Approved_by_NAM__c,Approved_by_Pricing__c,Cabin__c,Category__c,Fare_Combination__c,Market__c,Network__c,Proposal_Type__c,Qantas_Published_Airfare__c,QBS_Deafualt_Discount__c,Segment__c,TeamLead_Approved__c,DO_Approved__c FROM Fare_Structure_Lists__r),(SELECT Id,Contract_Agreement__c,Aircraft_Type__c,ETD__c,Flight_Date__c,Flight_Number__c,Seating_Space__c,Sector__c,Useable_Seats__c FROM Charter_Flight_Information__r),(SELECT Id,Amount__c,Contract_Agreement__c,Paid_As__c,Payment_Criteria__c,Payment_Frequency__c,Proposal__c,Type__c FROM Contract_Payments__r),(SELECT Market__c,Proposal__c,Aligned_with_EK_sales__c,Cost_of_sale_Incremental_opportunity__c,Current_performance_in_the_route_s__c,What_else_have_you_considered__c,How_did_you_arrive_with_this_proposal__c,Is_there_competitive_MI__c,Requested_routes__c,Supplementary_Materials_Sharepoint_Link__c,What_is_the_current_booking_mix__c FROM Justifications__r) FROM Proposal__c where Active__c=true AND Id=\'"+'{!Proposal__c.Id}'+"\' limit 1"; 

var records = sforce.connection.query(query); 
var records1 = records.getArray('records'); 


if(records1[0].Opportunity__r.StageName != 'Closed - Accepted' && records1[0].Opportunity__r.StageName != 'Closed - Not Accepted'){ 
// Contract Creation 

var proposal = new sforce.SObject("Proposal__c"); 

proposal.Name = records1[0].Name; 
proposal.Account__c = records1[0].Account__c; 
proposal.Active__c = true; 
proposal.Charter_Price__c = records1[0].Charter_Price__c; 
proposal.Commercial_TC__c = records1[0].Commercial_TC__c; 
proposal.Contact__c = records1[0].Contact__c; 
proposal.Domestic_Annual_Share__c = records1[0].Domestic_Annual_Share__c; 
proposal.International_Annual_Share__c = records1[0].International_Annual_Share__c; 
proposal.Legal_TC__c = records1[0].Legal_TC__c; 
proposal.Opportunity__c = records1[0].Opportunity__c; 
proposal.Qantas_Annual_Expenditure__c = records1[0].Qantas_Annual_Expenditure__c; 
proposal.Valid_From_Date__c = records1[0].Valid_From_Date__c; 
proposal.Type__c = records1[0].Type__c; 
proposal.Travel_Fund__c = records1[0].Travel_Fund__c; 
proposal.Travel_Fund_Amount__c = records1[0].Travel_Fund_Amount__c; 
proposal.Standard__c = records1[0].Standard__c; 
proposal.Additional_Change_Details__c = records1[0].Additional_Change_Details__c; 
proposal.Deal_Type__c = records1[0].Deal_Type__c; 
proposal.MCA_Routes_Annual_Share__c = records1[0].MCA_Routes_Annual_Share__c; 
proposal.Agent_Name__c = records1[0].Agent_Name__c; 
proposal.Agent_Fax__c = records1[0].Agent_Fax__c; 
proposal.Agent_Email__c = records1[0].Agent_Email__c; 
proposal.Agent_Address__c = records1[0].Agent_Address__c; 
proposal.Frequent_Flyer_Status_Upgrade__c = records1[0].Frequent_Flyer_Status_Upgrade__c; 
proposal.Frequent_Flyer_Status_Upgrade_Offer__c = records1[0].Frequent_Flyer_Status_Upgrade_Offer__c; 
proposal.Qantas_Club_Discount__c = records1[0].Qantas_Club_Discount__c; 
proposal.Qantas_Club_Discount_Offer__c = records1[0].Qantas_Club_Discount_Offer__c; 
proposal.TMC_Code__c = records1[0].TMC_Code__c; 
proposal.Qantas_Club_Join_Discount_Offer__c = records1[0].Qantas_Club_Join_Discount_Offer__c; 
proposal.Forecast_MCA_Revenue__c = records1[0].Forecast_MCA_Revenue__c; 
proposal.Reason_for_Discount__c	= records1[0].Reason_for_Discount__c; 
proposal.Proposal_End_Date__c	=records1[0].Proposal_End_Date__c; 

proposal.NAM_Approved1__c = records1[0].NAM_Approved1__c; 
proposal.Pricing_Approved1__c = records1[0].Pricing_Approved1__c; 
proposal.DO_Approved__c = records1[0].DO_Approved__c; 
if(records1[0].Status__c == 'Rejected - Internal' && records1[0].Leadership_Rejected__c == 'true'){ 
proposal.Approval_Required_Others__c = true; 
proposal.Approval_Required_Others__c = records1[0].Approval_Required_Others__c; 

if(records1[0].QIS_Rejected__c != 'true'){ 
proposal.TeamLead_Approved__c = records1[0].TeamLead_Approved__c; 

proposal.SBD_Approved__c = records1[0].SBD_Approved__c; 
proposal.QIS_Approved__c = records1[0].QIS_Approved__c; 
var rtype; 
if(records1[0].Type__c == 'Qantas Business Savings'){ 
rtype = 'QBS - Draft'; 
}else if(records1[0].Type__c == 'Corporate Airfares'){ 
rtype = 'CA - Draft'; 
}else if(records1[0].Type__c == 'Adhoc'){ 
rtype = 'Adhoc Charter - Approval Required - Customer'; 
}else if(records1[0].Type__c == 'Scheduled'){ 
rtype = 'Adhoc Charter - Approval Required - Customer'; 
var queryC = "SELECT Id, Name FROM RecordType where Name like '%"+rtype+"%' AND sObjectType='Proposal__c' limit 1"; 
var rtypes = sforce.connection.query(queryC); 
var rtypes1 = rtypes.getArray('records'); 
proposal.RecordTypeId = rtypes1[0].Id; 

var result = sforce.connection.create([proposal]); 


var discounts = records1[0].Fare_Structure_Lists__r; 

if(discounts != null){ 

// Discount List Creation 
var conDiscounts1 = discounts.getArray("records"); 
var discounts = []; 
for(var i=0; i<conDiscounts1.length; i++){ 
var discount = new sforce.SObject("Discount_List__c"); 
discount.Approval_Comment_NAM__c = conDiscounts1[i].Approval_Comment_NAM__c; 
discount.Approval_Comment_Pricing__c = conDiscounts1[i].Approval_Comment_Pricing__c; 
discount.FareStructure__c = conDiscounts1[i].FareStructure__c; 
discount.Comment__c = conDiscounts1[i].Comment__c; 
discount.Proposal__c = result[0].id; 
discount.Route_Origin__c =conDiscounts1[i].Route_Origin__c; 
discount.Discount__c = conDiscounts1[i].Discount__c; 
discount.Discount_Threshold_AM__c = conDiscounts1[i].Discount_Threshold_AM__c; 
discount.Discount_Threshold_NAM__c = conDiscounts1[i].Discount_Threshold_NAM__c; 
discount.Qantas_Published_Airfare__c = conDiscounts1[i].Qantas_Published_Airfare__c; 
discount.Approved_by_NAM__c = conDiscounts1[i].Approved_by_NAM__c; 
discount.Approved_by_Pricing__c = conDiscounts1[i].Approved_by_Pricing__c; 
discount.DO_Approved__c = conDiscounts1[i].DO_Approved__c; 
discount.Segment__c = conDiscounts1[i].Segment__c; 
discount.Category__c = conDiscounts1[i].Category__c; 
discount.Cabin__c = conDiscounts1[i].Cabin__c; 
discount.Fare_Combination__c = conDiscounts1[i].Fare_Combination__c; 
discount.Market__c = conDiscounts1[i].Market__c; 
discount.Network__c = conDiscounts1[i].Network__c; 
discount.Proposal_Type__c = conDiscounts1[i].Proposal_Type__c; 
discount.Qantas_Published_Airfare__c = conDiscounts1[i].Qantas_Published_Airfare__c; 
discount.QBS_Deafualt_Discount__c = conDiscounts1[i].QBS_Deafualt_Discount__c; 
if(records1[0].QIS_Rejected__c != 'true' && records1[0].Status__c != 'Rejected - Internal' ){ 

discount.TeamLead_Approved__c = conDiscounts1[i].TeamLead_Approved__c; 

var result1 = sforce.connection.create(discounts); 
var charters = records1[0].Charter_Flight_Information__r; 

if(charters != null){ 
//Charters creation 
var charters1 = charters.getArray("records"); 

var charterValues = []; 

for(var i=0; i<charters1.length; i++){ 
var charterValue = new sforce.SObject("Charter_Flight_Information__c"); 
charterValue.Proposal__c = result[0].id; 
charterValue.Aircraft_Type__c = charters1[i].Aircraft_Type__c; 
charterValue.ETD__c = charters1[i].ETD__c; 
charterValue.Flight_Date__c = charters1[i].Flight_Date__c; 
charterValue.Flight_Number__c = charters1[i].Flight_Number__c; 
charterValue.Seating_Capacity__c = charters1[i].Seating_Capacity__c; 
charterValue.Sector__c = charters1[i].Sector__c; 

var result2 = sforce.connection.create(charterValues); 


var payments = records1[0].Contract_Payments__r; 

if(payments != null){ 
//Contract Payment creation 
var payments1 = payments.getArray("records"); 

var paymentValues = []; 

for(var i=0; i<payments1.length; i++){ 
var paymentValue = new sforce.SObject("Contract_Payments__c"); 
paymentValue.Proposal__c = result[0].id; 
paymentValue.Amount__c = payments1[i].Amount__c; 
paymentValue.Contract_Agreement__c = payments1[i].Contract_Agreement__c; 
paymentValue.Paid_As__c = payments1[i].Paid_As__c; 
paymentValue.Payment_Criteria__c = payments1[i].Payment_Criteria__c; 
paymentValue.Payment_Frequency__c = payments1[i].Payment_Frequency__c; 
paymentValue.Type__c = payments1[i].Type__c; 

var result3 = sforce.connection.create(paymentValues); 


var business = records1[0].Justifications__r; 
if(business != null){ 
//Business Case creation 
var business1 = business.getArray("records"); 
var businessValues = []; 

for(var i=0; i<business1.length; i++){ 
var businessValue = new sforce.SObject("Business_Case__c"); 
businessValue.Proposal__c = result[0].id; 
businessValue.Aligned_with_EK_sales__c	= business1[i].Aligned_with_EK_sales__c; 
businessValue.Cost_of_sale_Incremental_opportunity__c = business1[i].Cost_of_sale_Incremental_opportunity__c; 
businessValue.Current_performance_in_the_route_s__c = business1[i].Current_performance_in_the_route_s__c; 
businessValue.What_else_have_you_considered__c = business1[i].What_else_have_you_considered__c; 
businessValue.How_did_you_arrive_with_this_proposal__c = business1[i].How_did_you_arrive_with_this_proposal__c; 
businessValue.Is_there_competitive_MI__c = business1[i].Is_there_competitive_MI__c; 
businessValue.Market__c = business1[i].Market__c; 
businessValue.Requested_routes__c = business1[i].Requested_routes__c; 
businessValue.Supplementary_Materials_Sharepoint_Link__c = business1[i].Supplementary_Materials_Sharepoint_Link__c; 
businessValue.What_is_the_current_booking_mix__c = business1[i].What_is_the_current_booking_mix__c; 

var result4 = sforce.connection.create(businessValues); 


window.location.href = '/'+result[0].id+'/e?retURL='+result[0].id; 

} else{ 
alert('Please note that you cannot create a proposal for a closed opportunity.'); 
}else if(records1.length==0){ 
alert("You can't clone in active Proposal."); 

alert('An Error has Occured. Error:' +e); 

Kindly help me pls

Thanks in advance
Hi Friends
One challenge i am facing for long a time.end user are entering the text field in hindi character with the help of keyboard.but that hindi character not supported in VF page PDF.is ther any way to achieve this type of issue.
Hi folks,

i want to create cookies in salesforce by @RemoteAction.