on 10-22-2014 6:18 AM
Hi All,
I'm trying to add two custom fields(date type& pull down text type) in My Opportunities App.
I can load and edit custom fields.
But I can't save custom fields for new opportunity.
I'm trying to code S5Custom.controller.js and opportunityCreateContentBottomExtensionCustom.fragment.xml.
*S5Custom.controller.js *
(the function is overwritten)
fill_dropDowns: function(s) {
/** overwrite function */
/* for custom field*/
var g = new sap.ui.model.json.JSONModel();
var h = {
SalesIntentions: [{
LanguageCode: "JA",
ProcessType: this.processType,
SalesIntention: "",
}]
};
for (i = 0; i < 3; i++) {
h.SalesIntentions.push({
LanguageCode: "JA",
ProcessType: this.processType,
SalesIntention: ""+10*(i+1)+"",
})
};
g.setData(h);
this.byId('salesIntention').setModel(g, "json");
},
dataConfirm: function(r) {
/** overwrite function */
//custom
var o = new Date(f.parse(this.byId('datePickerCompletionDate').getValue()));
var f = o.getFullYear() + "-" + (o.getMonth() + 1) + "-" + o.getDate() + "T00:00:00";
var E = {
//custom
CompletionDate: f,
//custom
SalesIntention: this.byId('salesIntention').getSelectedKey(),
*opportunityCreateContentBottomExtensionCustom.fragment.xml*
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:ui="sap.ui.layout" controllerName="cus.crm.opportunity.view.S5"
xmlns:ca="sap.ca.ui" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:custom="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">
<ui:form.SimpleForm id="form8" minWidth="1024"
maxContainerCols="2" editable="true" layout="ResponsiveGridLayout"
labelSpanL="3" labelSpanM="3" emptySpanL="4" emptySpanM="4"
columnsL="1" columnsM="1" class="editableForm">
<ui:content>
<Label id="completionDateLabel_S5" text="{i18n>COMPLETION_DATE}">
</Label>
<ca:DatePicker id="datePickerCompletionDate"
></ca:DatePicker>
</ui:content>
<ui:content>
<Label id="salesIntentionLabel_S5" text="{i18n>SALES_INTENTION}">
</Label>
<Select id="salesIntention" items="{json>/SalesIntentions}" class="pos_input">
<items>
<core:Item key="{json>SalesIntention}" text="{json>SalesIntention}">
</core:Item>
</items>
</Select>
</ui:content>
</ui:form.SimpleForm>
</core:FragmentDefinition>
1.New Opportunity
2.Select Save
3.Check Custom fields. Custom field can't save
4.Debug: the custom fields is stored in object
Kindly advice me proceed further.
Best Regards,
Yuki
Hi Yuki,
You would have to implement "extHookSaveOentry" controller hook from S5.controller.js. where you could append your custom fields to the "oEntry" json that would be sent as a payload to the POST request.
Regards, Masa
SAP Customer Experience Group - CEG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Masa,
Thank you for your response.
I implemented function the follow code.
But I can' save custom fields. The error message is nothing.
How do I append my custom fields to the "oEntry" json?
extHookSaveOentry: function(){
var m = this.getView().getModel();
var oEntry = {};
oEntry.CompletionDate = this.byId('datePickerCompletionDate').setValueState(sap.ui.core.ValueState.None);
oEntry.SalesIntention = this.byId('salesIntention').setSelectedKey("");
m.create("/Opportunities",oEntry, null);
},
Regards,
Yuki
Hi Yuki,
Inside the Dev tools on the Network tab, when you attempt to save your changes you should see a post request to the service being sent. Do you see the additional fields in the request?
Also do you have test data to verify that your custom fields are binded successfully from a read request?
Regards,
Jamie
SAP - Customer Experience Group
Hi Jamie,
Thank you for your responce.
Inside the Dev tools on the Network tab, when you attempt to save your changes you should see a post request to the service being sent. Do you see the additional fields in the request?
My case is to create new opportunity.
When I attempt to save new opportunity, I can get a post request.
When I see in the post request, the "Header" in Network tab have the additional fields.
But the "Response in Network tab don't have the additional fields.
Network tab:Header
Request URL:http://localhost:8080/Z_CRM_OPPRTNTY_01/proxy/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities
Request Method:POST
Status Code:201 Created
Request Headersview source
Accept:application/json
Accept-Encoding:gzip,deflate
Accept-Language:ja
Authorization:Basic c2FsZXNfbWFuOndlbGNvbWU=
Connection:keep-alive
Content-Length:695
Content-Type:application/json
Cookie:SAP_SESSIONID_KC1_800=7FXKf8DsUCs0lAPPA6Qw1JLHAS9e9hHkmDUAFV3SRgo%3d
DataServiceVersion:2.0
Host:localhost:8080
MaxDataServiceVersion:2.0
Origin:http://localhost:8080
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
x-csrf-token:d65_BHVJaRQWqTiwi6DZqQ==
Request Payloadview source
{Description:cus test3, ProcessType:Y002, StartDate:2014-10-29T00:00:00,…}
ChanceOfSuccess: ""
ClosingDate: "2014-10-29T00:00:00"
CompletionDate: "2014-10-30T00:00:00"
CurrencyCode: "JPY"
Description: "cus test3"
ExpectedSalesVolume: "10"
ForecastRelevance: false
Guid: "00000000-0000-0000-0000-000000000000"
MainContactName: ""
PriorityCode: ""
PriorityText: ""
ProcessType: "Y002"
Products: []
ProspectName: "Billing unit"
ProspectNumber: "4000004"
SalesIntention: "30"
SalesStageCode: ""
StartDate: "2014-10-29T00:00:00"
Statuses: [{HeaderGuid:00000000-0000-0000-0000-000000000000, StatusProfile:ZCRMOPPO, UserStatusCode:E0001,…}]
UserStatusCode: "E0001"
UserStatusText: "未処理"
Response Headersview source
content-encoding:gzip
Content-Length:556
Content-Type:application/json;charset=utf-8
dataserviceversion:2.0
Date:Tue, 28 Oct 2014 23:07:18 GMT
server:SAP NetWeaver Application Server / ABAP 731
Network tab:Response
{"d":{"__metadata":
"type":"ZCRM_OPPORTUNITY_SRV.Opportunity"},
"Guid":"00155DD2-460A-1ED4-97DE-E55DB337F835",
"Id":"",
"ProcessType":"Y002",
"Description":"cus test3",
"StartDate":"\/Date(1414540800000)\/",
"ClosingDate":"\/Date(1414540800000)\/",
"ExpectedSalesVolume":"0.10",
"CurrencyCode":"",
"SalesStageCode":"",
"SalesStageText":"",
"ChanceOfSuccess":"000",
"PriorityCode":"",
"PriorityText":"",
"ProspectNumber":"",
"ProspectName":"",
"UserStatusCode":"",
"UserStatusText":"",
"ForecastRelevance":false,
"MainContactId":"",
"MainContactName":"",
"EmployeeResponsibleNumber":"",
"EmployeeResponsibleName":"",
"SalesIntention":"",
"CompletionDate":null,
"Notes":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"ChangeDocs":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"Competitors":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"SalesTeam":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"Products":null,"Statuses":null,"Attachments":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"Account":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"ContactRel":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1..."}},
"EmployeeRel":{"__deferred":{"uri":"http://hostname:portnumber/sap/opu/odata/sap/ZCRM_OPPORTUNITY_SRV/Opportunities(guid'00155DD2-460A-1...
-POST Request
-Header
-
Also do you have test data to verify that your custom fields are binded successfully from a read request?
I can have test data in opportunity including my custom fields.
If I save new opportunity in WebClient UI or edit opportunity in Fiori,
I can see the test data including my custom fields, when I see the existing opportunity in Fiori.
Regards,
Yuki
Hi Masa,
Thank you for updating information.
I tried to test like your code.
But I can't save about custom fields.
If you found mistake in my code, please let me know.
extHookSaveOentry : function(oEntry){
//get data as json
var oModel = this.getView().getModel();
//array variables
var oEntry = {};
//Custom fields value
var f = sap.ca.ui.model.format.DateFormat.getDateInstance({
style: "medium"
}, new sap.ui.core.Locale(this.oAppImplementation.getResourceBundle().sLocale));
var o = new Date(f.parse(this.byId('datePickerCompletionDate').getValue()));
oEntry.SalesIntention = this.byId('salesIntention').getSelectedKey();
//post request for Service Url
oModel.create("/Opportunities",oEntry, null);
},
I confirm to add custom fields to Object in main create method parameter "E".
But I can't save custom fields.
Regards,
Yuki
Hi Jamie,
I am referring this document & SCN site for extend Fiori app.
'How to Extend Fiori Applications'
>How did you do the enhancement on the service?
I attempted to the follow process.
1.Append structure to add two custom fields.
T-cd:SE11 Data type :CRMT_ODATA_OPPT_HEADER
2.Copy standard Opportunity project in SAP NetWeaver Gateway Service Builder(T-cd:SEGW)
3.Redefine Odata Service
4.Add custom fields in Opportunity Entity Types's property .
5.Save and Generated
6.Add Service in T-cd:/IWFND/MSINT_SERVICE
7.Entry request URL, I can see the custom fields.
>Did you use the badl?
No, I didn't.
>Have you tested the service in the Gateway Client?
Yes. I can see the custom fields being filled in xml format.
Regards,
Yuki
Hi Jamie,
Custom Fields value in header is not available in the backend.
As I'm sure you a part of know, here are findings.
+ HTTP post method has custom fields value in the payload in above reply.
+ In the backend method, 'create deep entity' method for create opportunity don't have custom fields value.
The method is '/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY' in CLASS 'ZCL_ZCRM_OPPORTUNITY_DPC_EXT'
I confirmed that read and update method work fine without BADI or redefining method.
I think create method will work like update without any additional code.
Regards,
Yuki
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.