• Ciprian Stoica 12
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
Hi,

I'm stuck with this task.
We need to generate some pdf-s with dynamic data from the opportunity and add it to the account's attachments.
So my plan was to create a button which will generate a pdf from a visualforce page with all the necessary fields and some html and css formating and then save it under the account's files and attachments.

Can someone please give some hints on how this can be done?

Thanks
I wrote a POST method, which does all I need in terms of internal functionalities, but the response is not in the form I need.
Basically, I receive a list of product types and a quantity and I check it with a custom field in order to see if I have the necessary stock.
This is the method:
 
@HttpPost
    global static list<String> verifica_stoc(list<InfoCafea> ic) {
        
        list<String> result = new list<String>();
        for(InfoCafea Name:ic) {
            Decimal cantitate = [SELECT Cantitate__c FROM Cofee__c
                      WHERE Id = :Name.Cofee].Cantitate__c;
            if (Name.Order_Qty<= cantitate){
                String bau = 'Stock Unavailable';  
                result.add(bau);
                result.add(Name.Cofee);
                
            }else{
                String cau = 'Product available';
                result.add(cau);
                result.add(Name.Cofee);
            }
            }  
        return result;
    }    global class InfoCafea {
        global Decimal Order_Qty;
        global String Cofee;
    }
  }

This is the JSON I use for request:
{
    "ic" : [
                   { "Order_Qty" : "8", "Cofee" : "a010O000029R3b6QAC"},
                   { "Order_Qty" : "3", "Cofee" : "a010O000029R3baQAC"},
                   { "Order_Qty" : "10", "Cofee" : "a010O000029R3b6QAC"}
             ]
}

And here is the response:
[
    "Stock Unavailable",
    "a010O000029R3b6QAC",
    "Stock Unavailable",
    "a010O000029R3baQAC",
    "Stock Unavailable",
    "a010O000029R3b6QAC"
]
The information is all correct, but I need a response formatted like the request, so I would like something like this:
 
{
"list":[
{
"type":"cofee",
"status":"ok"
},
{
"type":"cofee2",
"status":"not ok"
}]
}
Thanks
 
Hi,

I'm creating a REST WebService that allows placing an order for a product.
Basically, I'm receiving an HTTP Post with a list of products and quantity.

When I receive the message my webservice creates a new order, but I can't seem to place the order.id as a parameter in my list json for each of the products.

My webservice is this:
 
global static list<Coffee_Order_Product__c> echoMyType(list<Coffee_Order_Product__c> ic) {
    Coffee_Order__c newOrder = new Coffee_Order__c();
        insert newOrder;
    for(Coffee_Order_Product__c:ic) {
        ic.add(newOrder.Id);
    }
    insert ic;    
    return ic;
    }
	 
}

my JSON should be:
{
    "ic" : [
                   { "Order_Qty__c" : "7", "Cofee__c" : "a010O000029R3b6QAC","Name" : "prod1"},
                   { "Order_Qty__c" : "4", "Cofee__c" : "a010O000029R3baQAC","Name" : "prod2"},
                   { "Order_Qty__c" : "1", "Cofee__c" : "a010O000029R3b6QAC","Name" : "prod3"}
             ]
}
I get an unexpected token ':' at line : for(Coffee_Order_Product__c:ic)

Any help please?

 
my use case is as follows: 

We want Gold Silver and Bronze accounts.
For each of them, I have a certain record in a custom object named "Loan Product" each with certain characteristics.
My need is to batch modify the records so that all accounts in that category are linked.

How can I match the different account type with the specific custom product type?
I will also need to access them through the API as in GET "loadproduct" for "account X" as in how you get field values from related objects.
For this, I will create a web service class after I get them matched somehow.

Any advices, please?
Hi,

I'm stuck with this task.
We need to generate some pdf-s with dynamic data from the opportunity and add it to the account's attachments.
So my plan was to create a button which will generate a pdf from a visualforce page with all the necessary fields and some html and css formating and then save it under the account's files and attachments.

Can someone please give some hints on how this can be done?

Thanks
I wrote a POST method, which does all I need in terms of internal functionalities, but the response is not in the form I need.
Basically, I receive a list of product types and a quantity and I check it with a custom field in order to see if I have the necessary stock.
This is the method:
 
@HttpPost
    global static list<String> verifica_stoc(list<InfoCafea> ic) {
        
        list<String> result = new list<String>();
        for(InfoCafea Name:ic) {
            Decimal cantitate = [SELECT Cantitate__c FROM Cofee__c
                      WHERE Id = :Name.Cofee].Cantitate__c;
            if (Name.Order_Qty<= cantitate){
                String bau = 'Stock Unavailable';  
                result.add(bau);
                result.add(Name.Cofee);
                
            }else{
                String cau = 'Product available';
                result.add(cau);
                result.add(Name.Cofee);
            }
            }  
        return result;
    }    global class InfoCafea {
        global Decimal Order_Qty;
        global String Cofee;
    }
  }

This is the JSON I use for request:
{
    "ic" : [
                   { "Order_Qty" : "8", "Cofee" : "a010O000029R3b6QAC"},
                   { "Order_Qty" : "3", "Cofee" : "a010O000029R3baQAC"},
                   { "Order_Qty" : "10", "Cofee" : "a010O000029R3b6QAC"}
             ]
}

And here is the response:
[
    "Stock Unavailable",
    "a010O000029R3b6QAC",
    "Stock Unavailable",
    "a010O000029R3baQAC",
    "Stock Unavailable",
    "a010O000029R3b6QAC"
]
The information is all correct, but I need a response formatted like the request, so I would like something like this:
 
{
"list":[
{
"type":"cofee",
"status":"ok"
},
{
"type":"cofee2",
"status":"not ok"
}]
}
Thanks
 
Hi,

I'm creating a REST WebService that allows placing an order for a product.
Basically, I'm receiving an HTTP Post with a list of products and quantity.

When I receive the message my webservice creates a new order, but I can't seem to place the order.id as a parameter in my list json for each of the products.

My webservice is this:
 
global static list<Coffee_Order_Product__c> echoMyType(list<Coffee_Order_Product__c> ic) {
    Coffee_Order__c newOrder = new Coffee_Order__c();
        insert newOrder;
    for(Coffee_Order_Product__c:ic) {
        ic.add(newOrder.Id);
    }
    insert ic;    
    return ic;
    }
	 
}

my JSON should be:
{
    "ic" : [
                   { "Order_Qty__c" : "7", "Cofee__c" : "a010O000029R3b6QAC","Name" : "prod1"},
                   { "Order_Qty__c" : "4", "Cofee__c" : "a010O000029R3baQAC","Name" : "prod2"},
                   { "Order_Qty__c" : "1", "Cofee__c" : "a010O000029R3b6QAC","Name" : "prod3"}
             ]
}
I get an unexpected token ':' at line : for(Coffee_Order_Product__c:ic)

Any help please?