-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
3Replies
Unable to add child records to an existing parent record
public with sharing class Ctrl_myWrapper{ public Id SaleBillId {get; set;} public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; } public List<Product_Invoice__c> Like_Products { get; set; } public String Name { get; set; } Sale_Bill__c sb = new Sale_Bill__c(); public Ctrl_myWrapper(ApexPages.StandardController controller) { Id SaleBillId = controller.getRecord().Id; Sale_Bill__c sb = [Select id,name from Sale_Bill__c where id = :SaleBillId Limit 1]; ProductsWrapped = new List<ProductInvoiceWrapper>(); Like_Products = new List<Product_Invoice__c>(); } public PageReference searchProduct() { String likeName = '%'+Name+'%'; Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c From Product_Invoice__c where Product_Name__c Like :likeName]; ProductsWrapped.clear(); for(Product_Invoice__c p : Like_Products ) { ProductsWrapped.add(new ProductInvoiceWrapper(p)); } return null; } public PageReference selectedProducts() { List<Sale_Transaction__c> newSaleTransactions = new List<Sale_Transaction__c>(); for(ProductInvoiceWrapper p : ProductsWrapped) { if(p.selected) { Sale_Transaction__c st = new Sale_Transaction__c(); st.Bill_ID__c = sb.Id ; st.Product_Invoice__c = p.pinv.Id; st.Quantity__c = p.Quantity; newSaleTransactions.add(st); } } insert newSaleTransactions; return null; } public class ProductInvoiceWrapper{ public Product_Invoice__c pinv {get; set;} public Boolean selected {get; set;} public Integer Quantity {get; set;} public ProductInvoiceWrapper(Product_Invoice__c a) { this.pinv = a; selected = false; this.Quantity = 0; } } }Error : Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Bill_ID]: [Bill_ID]
Error is in expression '{!selectedProducts}' in component <apex:commandButton> in page my_wrapper_demo: Class.Ctrl_myWrapper.selectedProducts: line 49, column 1
Sale_Transaction__c is a junction object between Product__Invoice__c and Sale_bill__c
Please do help
Thanks in advance
Allada Yeshwanth
-
- Allada Yeshwanth
- February 16, 2018
- Like
- 0
- Continue reading or reply
Problem in creating a wrapper class :
the records which are going into productswrapped are not being displayed in vf page
vf page: my wrapper demo
<apex:page controller="Ctrl_myWrapper">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Search" action="{!searchProduct}" reRender="Product-table" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="Product-table" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Name" />
<apex:inputText value="{!Name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockTable value="{!Like_Products}" var="pr" rendered="{!Like_Products.size>0}">
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputLink value="/{!pr.id}">{!pr.Product_Name__c}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">Quantity Remaining</apex:facet>
<apex:outputField value="{!pr.Quantity_Remaining__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Unit Price</apex:facet>
<apex:outputField value="{!pr.SellingPricePerUnit__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageblockSection title="Products" columns="1">
<apex:pageBlockTable value="{!ProductsWrapped}" var="prWrap" title="Products">
<apex:column >
<apex:inputCheckbox value="{!prWrap.selected}" />
</apex:column>
<apex:column >
<apex:facet name="header">id</apex:facet>
<apex:outputField value="{!prWrap.pinv.id}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller : Ctrl_myWrapper
public with sharing class Ctrl_myWrapper{
public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; }
public List<Product_Invoice__c> Like_Products { get; set; }
public String Name { get; set; }
public Ctrl_myWrapper()
{
ProductsWrapped = new List<ProductInvoiceWrapper>();
Like_Products = new List<Product_Invoice__c>();
}
public PageReference searchProduct()
{
String likeName = '%'+Name+'%';
Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c From Product_Invoice__c where Product_Name__c Like :likeName];
ProductsWrapped.clear();
for(Product_Invoice__c p : Like_Products )
{
ProductsWrapped.add(new ProductInvoiceWrapper(p));
}
return null;
}
public class ProductInvoiceWrapper{
public Product_Invoice__c pinv {get; set;}
public Boolean selected {get; set;}
public Integer Quantity {get; set;}
public ProductInvoiceWrapper(Product_Invoice__c a)
{
this.pinv = a;
selected = false;
Quantity = 0;
}
}
}
vf page: my wrapper demo
<apex:page controller="Ctrl_myWrapper">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Search" action="{!searchProduct}" reRender="Product-table" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="Product-table" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Name" />
<apex:inputText value="{!Name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockTable value="{!Like_Products}" var="pr" rendered="{!Like_Products.size>0}">
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputLink value="/{!pr.id}">{!pr.Product_Name__c}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">Quantity Remaining</apex:facet>
<apex:outputField value="{!pr.Quantity_Remaining__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Unit Price</apex:facet>
<apex:outputField value="{!pr.SellingPricePerUnit__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageblockSection title="Products" columns="1">
<apex:pageBlockTable value="{!ProductsWrapped}" var="prWrap" title="Products">
<apex:column >
<apex:inputCheckbox value="{!prWrap.selected}" />
</apex:column>
<apex:column >
<apex:facet name="header">id</apex:facet>
<apex:outputField value="{!prWrap.pinv.id}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller : Ctrl_myWrapper
public with sharing class Ctrl_myWrapper{
public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; }
public List<Product_Invoice__c> Like_Products { get; set; }
public String Name { get; set; }
public Ctrl_myWrapper()
{
ProductsWrapped = new List<ProductInvoiceWrapper>();
Like_Products = new List<Product_Invoice__c>();
}
public PageReference searchProduct()
{
String likeName = '%'+Name+'%';
Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c From Product_Invoice__c where Product_Name__c Like :likeName];
ProductsWrapped.clear();
for(Product_Invoice__c p : Like_Products )
{
ProductsWrapped.add(new ProductInvoiceWrapper(p));
}
return null;
}
public class ProductInvoiceWrapper{
public Product_Invoice__c pinv {get; set;}
public Boolean selected {get; set;}
public Integer Quantity {get; set;}
public ProductInvoiceWrapper(Product_Invoice__c a)
{
this.pinv = a;
selected = false;
Quantity = 0;
}
}
}
-
- Allada Yeshwanth
- February 16, 2018
- Like
- 0
- Continue reading or reply
Uncaught Action failed: c:InTheArea$controller$doInit [Cannot read property 'setParams' of undefined] Callback failed: aura://ComponentController/ACTION$getComponent
can someone help how to correct this error
Uncaught Action failed: c:InTheArea$controller$doInit [Cannot read property 'setParams' of undefined]
Callback failed: aura://ComponentController/ACTION$getComponent
thank you
Uncaught Action failed: c:InTheArea$controller$doInit [Cannot read property 'setParams' of undefined]
Callback failed: aura://ComponentController/ACTION$getComponent
thank you
-
- Allada Yeshwanth
- September 14, 2017
- Like
- 0
- Continue reading or reply
Unable to add child records to an existing parent record
public with sharing class Ctrl_myWrapper{ public Id SaleBillId {get; set;} public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; } public List<Product_Invoice__c> Like_Products { get; set; } public String Name { get; set; } Sale_Bill__c sb = new Sale_Bill__c(); public Ctrl_myWrapper(ApexPages.StandardController controller) { Id SaleBillId = controller.getRecord().Id; Sale_Bill__c sb = [Select id,name from Sale_Bill__c where id = :SaleBillId Limit 1]; ProductsWrapped = new List<ProductInvoiceWrapper>(); Like_Products = new List<Product_Invoice__c>(); } public PageReference searchProduct() { String likeName = '%'+Name+'%'; Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c From Product_Invoice__c where Product_Name__c Like :likeName]; ProductsWrapped.clear(); for(Product_Invoice__c p : Like_Products ) { ProductsWrapped.add(new ProductInvoiceWrapper(p)); } return null; } public PageReference selectedProducts() { List<Sale_Transaction__c> newSaleTransactions = new List<Sale_Transaction__c>(); for(ProductInvoiceWrapper p : ProductsWrapped) { if(p.selected) { Sale_Transaction__c st = new Sale_Transaction__c(); st.Bill_ID__c = sb.Id ; st.Product_Invoice__c = p.pinv.Id; st.Quantity__c = p.Quantity; newSaleTransactions.add(st); } } insert newSaleTransactions; return null; } public class ProductInvoiceWrapper{ public Product_Invoice__c pinv {get; set;} public Boolean selected {get; set;} public Integer Quantity {get; set;} public ProductInvoiceWrapper(Product_Invoice__c a) { this.pinv = a; selected = false; this.Quantity = 0; } } }Error : Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Bill_ID]: [Bill_ID]
Error is in expression '{!selectedProducts}' in component <apex:commandButton> in page my_wrapper_demo: Class.Ctrl_myWrapper.selectedProducts: line 49, column 1
Sale_Transaction__c is a junction object between Product__Invoice__c and Sale_bill__c
Please do help
Thanks in advance
Allada Yeshwanth
- Allada Yeshwanth
- February 16, 2018
- Like
- 0
- Continue reading or reply
Problem in creating a wrapper class :
the records which are going into productswrapped are not being displayed in vf page
vf page: my wrapper demo
<apex:page controller="Ctrl_myWrapper">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Search" action="{!searchProduct}" reRender="Product-table" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="Product-table" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Name" />
<apex:inputText value="{!Name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockTable value="{!Like_Products}" var="pr" rendered="{!Like_Products.size>0}">
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputLink value="/{!pr.id}">{!pr.Product_Name__c}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">Quantity Remaining</apex:facet>
<apex:outputField value="{!pr.Quantity_Remaining__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Unit Price</apex:facet>
<apex:outputField value="{!pr.SellingPricePerUnit__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageblockSection title="Products" columns="1">
<apex:pageBlockTable value="{!ProductsWrapped}" var="prWrap" title="Products">
<apex:column >
<apex:inputCheckbox value="{!prWrap.selected}" />
</apex:column>
<apex:column >
<apex:facet name="header">id</apex:facet>
<apex:outputField value="{!prWrap.pinv.id}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller : Ctrl_myWrapper
public with sharing class Ctrl_myWrapper{
public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; }
public List<Product_Invoice__c> Like_Products { get; set; }
public String Name { get; set; }
public Ctrl_myWrapper()
{
ProductsWrapped = new List<ProductInvoiceWrapper>();
Like_Products = new List<Product_Invoice__c>();
}
public PageReference searchProduct()
{
String likeName = '%'+Name+'%';
Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c From Product_Invoice__c where Product_Name__c Like :likeName];
ProductsWrapped.clear();
for(Product_Invoice__c p : Like_Products )
{
ProductsWrapped.add(new ProductInvoiceWrapper(p));
}
return null;
}
public class ProductInvoiceWrapper{
public Product_Invoice__c pinv {get; set;}
public Boolean selected {get; set;}
public Integer Quantity {get; set;}
public ProductInvoiceWrapper(Product_Invoice__c a)
{
this.pinv = a;
selected = false;
Quantity = 0;
}
}
}
vf page: my wrapper demo
<apex:page controller="Ctrl_myWrapper">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Search" action="{!searchProduct}" reRender="Product-table" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="Product-table" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Name" />
<apex:inputText value="{!Name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockTable value="{!Like_Products}" var="pr" rendered="{!Like_Products.size>0}">
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputLink value="/{!pr.id}">{!pr.Product_Name__c}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">Quantity Remaining</apex:facet>
<apex:outputField value="{!pr.Quantity_Remaining__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Unit Price</apex:facet>
<apex:outputField value="{!pr.SellingPricePerUnit__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageblockSection title="Products" columns="1">
<apex:pageBlockTable value="{!ProductsWrapped}" var="prWrap" title="Products">
<apex:column >
<apex:inputCheckbox value="{!prWrap.selected}" />
</apex:column>
<apex:column >
<apex:facet name="header">id</apex:facet>
<apex:outputField value="{!prWrap.pinv.id}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller : Ctrl_myWrapper
public with sharing class Ctrl_myWrapper{
public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; }
public List<Product_Invoice__c> Like_Products { get; set; }
public String Name { get; set; }
public Ctrl_myWrapper()
{
ProductsWrapped = new List<ProductInvoiceWrapper>();
Like_Products = new List<Product_Invoice__c>();
}
public PageReference searchProduct()
{
String likeName = '%'+Name+'%';
Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c From Product_Invoice__c where Product_Name__c Like :likeName];
ProductsWrapped.clear();
for(Product_Invoice__c p : Like_Products )
{
ProductsWrapped.add(new ProductInvoiceWrapper(p));
}
return null;
}
public class ProductInvoiceWrapper{
public Product_Invoice__c pinv {get; set;}
public Boolean selected {get; set;}
public Integer Quantity {get; set;}
public ProductInvoiceWrapper(Product_Invoice__c a)
{
this.pinv = a;
selected = false;
Quantity = 0;
}
}
}
- Allada Yeshwanth
- February 16, 2018
- Like
- 0
- Continue reading or reply