• Behzad Bahadori 18
  • NEWBIE
  • 155 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 51
    Questions
  • 67
    Replies
I have a javascript object that looks like this
this will be used in an ajax called in javascript  data: JSON.stringify(address) and submitted
var address = { location: { 
                                    phoneNumber: "", 
                                    address: {
                                    line1: $( "line1" ).val(),
                                    city: $( "city" ).val(), 
                                    state: $( "state" ).val(), 
                                    postalCode: $( "postalCode" ).val(),
                                    country: "US", 

                                            }
                                  }, 
                        networks: ["1", "2","3","4","5"],  
                        company: "Salesforce"
                      };

what I need to do is samething but in apex code with custom object but not sure how I can format it same way

qualRequest = new prequalAPI.QualificationRequest();   
qualRequest.CustomerId = 0;
            qualRequest.PhoneNumber = 'STANDALONE';
            qualRequest.AddressLine1 = addressLine1;

            if (unitType != null)
            {
                qualRequest.UnitType = unitType;
            }

            if (unitValue != null)
            {
                qualRequest.UnitValue = unitValue;
            }

            qualRequest.City = city;
            qualRequest.State = state;
            qualRequest.ZipCode = zip;
            qualRequest.Country = country;
            qualRequest.UnitType = unitType;
            qualRequest.RequestedNetworkNames = new List<String>();
            qualRequest.RequestedNetworkNames.add('1');
            qualRequest.RequestedNetworkNames.add('2');
            qualRequest.RequestedNetworkNames.add('3');
            qualRequest.RequestedNetworkNames.add('4');
            qualRequest.RequestedNetworkNames.add('5');

JSON.serialize(qualRequest);
my request status fails right now because json is not same format. 
Currently I am trying to block certain profiles from changing UnitPrice within Quote. I used validation rules under customize> QuoteLineItem and worked perfectly fine. However those validation rules only work when the product has been already added. The Issue I have right now; is when the user adds a product inside quote by clicking on "Add Line Item" they are prompted to a page where they can enter quantity. There is also a UnitPrice there as well. They are still allowed to change the price. I am not sure how i can access that page and how I can disable that field within the page. I thought the below trigger could do it, but I am not sure how to add certain profile or even where do i add that trigger to for this page.
User-added image
how do I add profile to this, and also this didnt work 
 
OR( 
AND(ISNEW(), NOT(ISNULL(UnitPrice)), 
AND(NOT(ISNEW()), ISCHANGED(UnitPrice))) 
)


 
I have the following ajax call that I am sending to an outside domain. but it straights goes to error function is there something that I am missing . I have added the url into remote setting
 
$.ajax({
             type: "POST",
             url: 'https://xxx.xxx.xxx/qualification',
             headers: {"Accept" : "application/json",
                        "Content-Type": "application/json" },
             data: JSON.stringify(address),
             crossDomain : true,
             dataType: 'json',
             success: function (responseData) {
                console.log(responseData);
            getAddresses();

            },
            error: function (request, status, error) {
                console.log(request.responseText);
                console.log(status);
                console.log(error);
                var result = $("#selections").append("Sorry, Something in the system has gone wrong , Please try again Later");
                console.log("Sorry, Something in the system has gone wrong , Please try again Later");
            }

        });
the error "Sorry, Something in the system has gone wrong , Please try again Later" but in console I also get this. I am not sure if there anything script cdn i need to include or if the format is wrong. any hint is really appriciated 

<message collected>
error
 <message collected>
I have the following drop down, and I want to send the value of the selected file to my controller .. so if the user selects parent account1 my controller should get that value or if they select parent account2 samething 
<label>Select the Region</label>
                </td>
                <td class="data2Col" style="border-bottom:0px;">
                    <select id="sandler" class="sandler" value="{!regionAccount}">
            <option value=""></option>
            <option value='ParentAccount1'>asdf--zz</option>
            <option value='ParentAccount2'>ggggg</option>
        
        </select>
        </td>
// Recieve the Region Value from Visual Force Page.. 
   public String regionAccount{get;set;}
    public Account regionAccountId{get;set;}
// if regional is not empty 
if (regionAccount != Null ){


      // get the value of region and find the accountId
        regionAccountId = [select Id  from Account where Name = : regionAccount];
        account.ParentId =regionAccountId.Id;
    
 
        }
        else{
        for (Contact parents : parentAccount)
        {
            System.debug('Now I get to here part 2');
            account.ParentId = parents.AccountId;
        }
    }


 
I need to Query the Last notes and attachments that was added in a Quote, into a PDF, I dont now how to query that , any suggestions?
How do I write a unit test for 
QuoteDocument qd = new QuoteDocument();
        qd = [SELECT CreatedById, CreatedDate, IsDeleted, Discount, GrandTotal, LastModifiedById, LastModifiedDate, Name, Document, QuoteId, Id, SystemModstamp 
              FROM QuoteDocument 
              WHERE QuoteId =: urlId
        Limit 1];
     
         blst.add(EncodingUtil.base64Encode(qd.Document));
         System.debug('the size of the file' + qd.Document.size());


           
        
         String formatJSON = JSON.serializePretty(blst);

record = new Document( FolderId = UserInfo.getUserId() ,AuthorId=UserInfo.getUserId(), Name = Name +'_' + datetime.now() +'.pdf', Body = b  ,ContentType='application/pdf;charset=UTF-8');

        
        System.debug('Record' + record);
        insert record;

 
I have a list and list should Contain a certain document that has an ID 


    List<String> blst = new List<String>();
    

      System.debug('inside the empty folder to set up the proposal');
                c = [SELECT Id, Name, Body
                         from Document
                        Where Id =: FoId];  
                        System.debug('Adding one file to the PDF ');
                blst.add(EncodingUtil.base64Encode(c.Body)); 
        

my unit test its keep telling me the id is empty even tho I make sure FoID is assign

Unit test FoId= '123456';

how can I test that 
How Do I make a test case for this 
public String ourl {get;set;}
	public String url {get;set;} 
	Blob content;
	public NewPdfQuote() {

		url = ApexPages.currentPage().getParameters().get('qotId');
		generateNewQuotePDF();

	}

	     public  QuoteDocument generateNewQuotePDF(){
          
        ourl = '/apex/QuotePDF?id=' + url ;

        System.debug('ourl   ' + ourl);

        PageReference pr = Page.QuotePDF;
        pr.getParameters().put('id', url);

        System.debug('saveQuote() Quote: ' + url);

        if (!Test.isRunningTest())
            content = pr.getContentAsPDF();
        else
            content = Blob.valueOf('Unit Test Attachment Body');

       
         //emailURL = '/_ui/core/email/author/EmailAuthor?p3_lkid=' + urlId + '&doc_id=' + record.Id + '&retURL=%2F' + urlId ;
        return NULL;
  
    }

    	 public PageReference sendQuote()
   			 {
				     QuoteDocument doc1 = new QuoteDocument(Document = content, QuoteId = url);

				       // Database.SaveResult insertResult = Database.Insert(doc, false);
				        insert doc1;
				        return NULL;
		}

 
Hi , I have created Custom pdf with a wizard that we use , but now I need to create custom button inside Quote which gets the Quoteline Item , or the Quote ID and pas it to my PDF, I dont knwo how I can make button that will get atleast Quote ID . if I get the Quote ID I might be able to to just pass that to my PDF Apex and create new one