CDS published via #OData.publish not visible in /IWFND/MAINT_SERVICE - web-services

Created a CDS view with OData exposure in Eclipse. View activated and working correctly, I can see the SQL View data using se16N. View definition below:
#AbapCatalog.sqlViewName: 'ZDDLS_ODATA'
#AbapCatalog.compiler.CompareFilter: true
#AbapCatalog.preserveKey: true
#AccessControl.authorizationCheck: #CHECK
#EndUserText.label: 'TEST CDS Association II'
#Search.searchable: true
#OData.publish: true
define view ZCDSV_ODATA as select from vbak as soHdr
association [1..*] to ZCDSV_PROD as _itemprod
on $projection.vbeln = _itemprod.vbeln {
key soHdr.vbeln,
soHdr.auart,
_itemprod.posnr,
_itemprod.matnr,
_itemprod.arktx,
_itemprod.mtart,
_itemprod.mbrsh,
_itemprod // Make association public
}
where auart = 'ZINT'
Next step is supposed to be registering the service via /n/IWFND/MAINT_SERVICE. Here is the problem. Entry (unlike the ones created in SEGW) is not available when pushing the "Add Service" button.
This is not a S4/HANA system (installed products below), could this be a release issue?

could this be a release issue?
Yes, you are right. Publishing CDS entities as OData is supported since ABAP AS Netweaver 7.50 SP00.

Related

Oracle APEX - How to populate interactive grid using APEX collection

I am new to developing application using oracle apex. Please excuse me if this question seems very trivial in nature.
In a nutshell, I am trying to invoke a REST service programmatically to populate an interactive grid on oracle apex page. Here's what I already tried.
Created a page that has a button to invoke a process.
The process invokes a REST service to get all order lines belonging to a particular order. The sample response from the REST service is as below
{
"items": [{
"HeaderId": 300100550016803,
"FulfillLineId": 300100550016806,
"SourceTransactionLineId": "1",
"SourceTransactionLineNumber": "1",
"OrderedQuantity": "10",
"OrderedUOM": "Each",
"RequestedFulfillmentOrg": "Vision Corporation"
},{
"HeaderId": 300100550016803,
"FulfillLineId": 300100550016807,
"SourceTransactionLineId": "2",
"SourceTransactionLineNumber": "2",
"OrderedQuantity": "15",
"OrderedUOM": "Each",
"RequestedFulfillmentOrg": "Seattle Manufacturing"
}]
}
If the rest service invocation was successful (http status code: 200), then I create the apex_collection as below in the same process. Also, I have set one of the page fields (P3_REFRESH_ORDER_LINES_GRID) to ‘Y'. On page load, the value for this attribute must be null.
if apex_web_service.g_status_code = 200 then --OK
dbms_output.put_line( 'Response : ' || l_data ); --if response was OK, print it
apex_collection.create_or_truncate_collection( 'OrderLines' );
apex_collection.add_member(
p_collection_name => 'OrderLines',
p_clob001 => l_data );
:P3_REFRESH_ORDER_LINES_GRID := 'Y';
end if;
I have then used the below SQL query to populate data into the interactive grid
Set the region type to “Interactive Grid”
Source: Local Database
Type: SQL query
SELECT ol.fulfill_line_id as FulfillLineId, ol.quantity as Quantity
FROM APEX_collections c,
JSON_TABLE(
c.clob001, -- the following lines depend on your JSON structure
'$.items[*]'
columns(
fulfill_line_id number path '$.FulfillLineId',
quantity number path '$.OrderedQuantity')
) ol
WHERE c.collection_name = 'OrderLines';
Then, I have setup a dynamic action on the page item (Its a hidden text field)
- P3_REFRESH_ORDER_LINES_GRID
- Dynamic Action name : RefreshGrid
- When: Event Name: Change
- selection type: Item
- Item - P3_REFRESH_ORDER_LINES_GRID
- Client side condition - Type: Item is not null
- Item - P3_REFRESH_ORDER_LINES_GRID
- True condition: Action: Refresh, selection type: Region, Region: Order Lines (Name of the region containing the IG)
After I click on the button to invoke the rest service to fetch the order lines, the interactive grid does not display any data. Can you suggest where am I going wrong here?
Potential Issue(s)
Step 1 You didn't really specify how your button works. If it is submitting the page, you may have problems with P3_REFRESH_ORDER_LINES_GRID field remaining null.
You could have Server-Side conditions preventing the invocation or on Page-Load you may be resetting P3_REFRESH_ORDER_LINES_GRID to null, and Step 5 will NOT trigger.
Step 3(Most Likely Issue) If you are not submitting the page, and you just have a Dynamic Action, executing Server-Side code: you may have forgotten to include P3_REFRESH_ORDER_LINES_GRID in the Items to Return.
Your P3_REFRESH_ORDER_LINES_GRID flag will remain null and Step 5 will NOT trigger.
To Debug
You can try debugging your page here by checking Session under Developer Tools. I would make sure each step work and executes however I intend it to execute.
Also leverage APEX_DEBUG in my PL/SQL
Open your Browser's Developer Tools and look under Console. You should see Dynamic Action Fired lines there if Step 5 is being triggered at all!
As you have not shared how your debugging went, and other observations after clicking the button, such as:
Was the collection created?
Is there data in the collection?
What's the value of P3_REFRESH_ORDER_LINES_GRID
You should be able to see what the answers are for the above using Session.

How to get item attributes via api?

We are using cloud Dynamics 365 Business Central and trying to get items with all attributes via OData.
In Microsoft documentation we found this endpoint:
api.businesscentral.dynamics.com/v1.0[our tenant id]/Sandbox/ODataV4/Company('CRONUS%20DE')/items
But unfortunately, the response does not contain item attributes and values, such as Farbe, Tiefe, etc.
Next, we tried to add new Web Services. But some of this endpoints return empty values and some of them (7506, 7507, 7508, 7510) don't work and return:
No HTTP resource was found that matches the request URI
Objects 7500, 7501, 7503 contain information about attributes. But non of them (7500 - 7510) does not contain a relation between Item, Attributes, and Values.
Maybe there is another way to get items with their attribute values? We also tried to research microsoft graph but not successful.
i am having similar troubles with this. i find the dynamics api to be exceptionally unintuitive and difficult to use. the furthest i have been able to get has been to go into the api settings for dynamics and uncover the tables for a few item attributes (i believe that the table numbers are as those below:
7500 - Item Attribute
7501 - Item Attribute Value
7502 - Item Attribute Translation
7504 - Item Attribute Value Selection
7505 - Item Attribute Value Mapping
i cannot comment on why 7503 is missing.
using 7500 as an example, when you uncover the table, the system provides a resulting endpoint (unfortunately, they always promote OData, and the outdated SOAP resource; i can't figure out why they have such a vendetta against the simple and easy-to-use REST endpoint).
https://api.businesscentral.dynamics.com/v2.0/<TENANT_ID>/<ENVIRONMENT_NAME>/ODataV4/Company('COMPANY_IDENTIFIER')/ItemAttributes
using this endpoint, you can get a listing of the attribute types themselves (e.g. let's say you've defined an attribute called 'BaseColor', you should get a result here for the name of the attribute 'BaseColor', its ID, its type, etc.),
with the ItemAttributeValues endpoint, you should get the actual attribute values that are in existence (e.g. for some item, you happened to set its 'BaseColor' attribute to 'Blue', you should get a response for this attribute value with a attribute type of 'BaseColor', a value, as 'Blue' along with the entity's ID, etc).
yet, when it comes to any instantiated attribute values for items, i can't figure out how to get the association of the attributes with those items. i expect that the "item attribute value mapping" option would be something along the lines of a item_id - attribute_id pair so that for any item in question, one could query the attributes list with something like a filter. but as you said, upon uncovering some of these elements, their respective endpoints return nothing. you get to the point where you say 'OH...AWSOME! there is a value-item mapping. that makes sense, and i can definitely use that'. a few moments later, the API spits in your face with an error, or craps on you by returning something you don't expect like an empty data set.
this api is a constant uphill battle, and totally riddled with landmines. a complete blow-me-up-pain-in-the-arse.
EDIT: 2021-06-09
i've looked into this some more. i was able to set up an export package for the various tables in question, specifically 7500, 7501, and 7505. the magical table was 7505 as it is the relationship between an attribute value and the item with which it is associated. exporting the package to excel results in good data. yet, when trying to expose this information in the OData resource, something strange happens:
in web services, i try to open up page 7505 which populates the object name as ItemAttributeValueMapping and i set the service name to 'ItemAttributeValueMapping'. This is normal.
the system complains when i fail to specify that the object type is a page. so, i go back in the line and set the selection to "Page"
when i tab through to publish the change, the object name automatically changes to 'ItemAttributeValueTranslations'.
EDIT: 2021-06-15
After a lot of fiddling about, i finally reached a point where i decided that the only way to address this was to write an al query which would expose the appropriate value-item mapping information. there is a page which provides some source code for doing this:
github AL-Code-Samples
to get something out of the API, i had to use microsoft visual studio code. there are a few good videos on how to get this up and running to get a test app working for your business central instance (i used eric hougaar's videos: Getting started with Business Central AL Development).
when you have set up your app to connect to your instance by inserting your tenant and entering your credentials, you can modify the source code as below to create a query in your system.
query 50102 "<YOUR_QUERY_NAME>"
{
QueryType = API;
APIPublisher = '<YOUR_NAME>';
APIGroup = '<YOUR_APP_GROUP>';
APIVersion = 'v1.0';
Caption = '<YOUR CAPTION>';
EntityName = '<YOUR_QUERY_NAME>';
EntitySetName = '<YOUR_API_ENDPOINT_NAME>';
elements
{
dataitem(Item; Item)
{
column(No_; "No.")
{
}
column(Description; Description)
{
}
column(Unit_Cost; "Unit Cost")
{
}
dataitem(Item_Attribute_Value_Mapping; "Item Attribute Value Mapping")
{
DataItemLink = "No." = Item."No.";
column(Item_Attribute_ID; "Item Attribute ID")
{
}
column(Item_Attribute_Value_ID; "Item Attribute Value ID")
{
}
dataitem(QueryElement6; "Item Attribute")
{
DataItemLink = ID = Item_Attribute_Value_Mapping."Item Attribute ID";
column(Name; Name)
{
}
dataItem(Queryelement10; "Item Attribute Value")
{
DataItemLink = "Attribute ID" = Item_Attribute_Value_Mapping."Item Attribute ID",
ID = Item_Attribute_Value_Mapping."Item Attribute Value ID";
column(Value; Value)
{
}
column(Numeric_Value; "Numeric Value")
{
}
}
}
}
}
}
}
once this code gets successfully uploaded to your server and returning a page (you have to wait for it), you can then use specified query number to expose the data in the API by going to business central's "web services" and adding a 'Query' to item 50102 (or whatever number you use). the endpoint will automatically be populated and you can use it to send you back the necessary JSON which will show a product, with its attribute values.
hope that helps.
You should try with below endpoint:
/v2.0/tenant_id/enviornment_name/ODataV4/Company(company_id)/Items

Create NewRecord through Siebel Business Service eScript

I am trying to create a new record using BS server script.
Since the process is taking place inside the BS, the context of Parent is not present, hence I am unable to get Parent Row_Id which I need to explicitly stamp against the child record being created for visibility.
Initially I tried to pass the Parent Row_Id from applet as a profile, but this fails when there are no records in the child applet, ie this.BusComp().ParentBusComp().GetFieldValue returns "This operation is invalid when there are no records present" as the "this" context is unavailable.
Any suggestions?
I was able to achieve the desired with the below code
sId = TheApplication().ActiveBusObject().GetBusComp("Q").ParentBusComp().GetFieldValue("Id");
if(this.BusComp().CountRecords() > 0)
{
sA = TheApplication().ActiveBusObject().GetBusComp("Q").GetFieldValue("A");
sB = TheApplication().ActiveBusObject().GetBusComp("Q").GetFieldValue("B");
}
sEntity = TheApplication().ActiveBusObject().GetBusComp("Q").Name();
It is for these reasons that Siebel provides Pre-Default settings at the Business Component Field level. If you wish to do this entirely through scripting, you will have to find the Active context, you have to know which BC is the parent.
Lets say you know that the Parent BC has to be Account. So
ActiveBusObject().GetBusComp("Account").GetFieldValue("Id") will give you the row id of the currently selected Account BC record. But do make sure that this script fires only in this context. So check the ActiveViewName to check this.
if(TheApplication().GetProfileAttr("ActiveViewName")=="Custom View")
{
//put the scripting here.
}

Sitecore WFFM: Issues Submitting form programmatically

I have been trying to submit a my own form to WFFM. The form I created is identical to the one created with WFFM, that way all fields map correctly.
I began following the following steps: https://jermdavis.wordpress.com/2015/05/18/programmatic-wffm-submissions/
I had to make minor changes to the code in order to get the SubmitActionManager to work
The members of Sitecore.Form.Core.Submit.SubmitActionManager class
have been moved to the IActionExecutor interface.To obtain the
instance of this interface use the
(IActionExecutor)Factory.CreateObject ("wffm/wffmActionExecutor",
false) call.
Below is the code I have so far:
public void SubmitData(ContactUsFormModel data)
{
var results = new List<ControlResult>();
results.Add(makeControlResult(Models.Constants._cufFirstNameID, "First Name", data.FirstName));
results.Add(makeControlResult(Models.Constants._cufLastNameID, "Last Name", data.LastName));
results.Add(makeControlResult(Models.Constants._cufEmailID, "Email", data.Email));
results.Add(makeControlResult(Models.Constants._cufCompanyID, "Company", data.Company));
results.Add(makeControlResult(Models.Constants._cufSubjectID, "Subject", data.Subject));
results.Add(makeControlResult(Models.Constants._cufMessageID, "Message", data.Message));
var formItem = Sitecore.Context.Database.GetItem(Models.Constants._contactUsFormID);
var simpleForm = new SitecoreSimpleForm(formItem);
var saveActionXml = simpleForm.FormItem.SaveActions;
var actionList = Sitecore.Form.Core.ContentEditor.Data.ListDefinition.Parse(saveActionXml);
var actionDefinitions = new List<ActionDefinition>();
actionDefinitions.AddRange(actionList.Groups.SelectMany(x => x.ListItems).Select(li => new ActionDefinition(li.ItemID, li.Parameters) { UniqueKey = li.Unicid }));
var SubmitActionManager = (IActionExecutor)Factory.CreateObject("wffm/wffmActionExecutor", false);
Sitecore.Form.Core.WffmActionEvent sessionID = new Sitecore.Form.Core.WffmActionEvent();// SessionIDGuid
var result = SubmitActionManager.ExecuteSaving(ID.Parse(Models.Constants._contactUsFormID), results.ToArray(), actionDefinitions.ToArray(), true, ID.Parse( sessionID.SessionIDGuid ));
}
private ControlResult makeControlResult(string fieldID, string fieldName, string fieldValue)
{
return new ControlResult(fieldName, fieldValue, string.Empty)
{
FieldID = fieldID,
FieldName = fieldName,
Value = fieldValue,
Parameters = string.Empty
};
}
I wasnt sure where to get Sitecore.Form.Core.Analytics.AnalyticsTracker.SessionId from to use it inside ExecuteSaving, so I used WffmActionEvent.
Also the guide I followed uses Execute, which is now deprecated, so I had to go with ExecureSaving (my best guess).
This however doesn't seem to be posting the submitted data into the databse. I am unable to see any of my submissions inside WFFM Form Reports or inside mongoDB.
The logs however state that the form is being saved to the database, not sure what the other warnings mean.
24688 17:20:39 WARN [WFFM] Tracker.Current is not initialized
24688 17:20:39 INFO AUDIT (sitecore\admin): [WFFM] Form {978DBF4C-0F56-45A8-A9AC-52EF8D995DDF} is saving to db
24688 17:20:39 WARN [WFFM] Tracker.Current.Contact is not initialized
24688 17:20:39 WARN [WFFM] Tracker.Current.Interaction is not initialized
24688 17:20:39 WARN [WFFM] CurrentSession is not initialized
As you are using Sitecore 8 the form submission is stored in MongoDB. Sitecore's implementation of MongoDB, xDB mostly relies on tracking users, calling them Contacts.
Most data stored in xDB is linked to a Contact via a ContactId. The error messages you are finding in the log are stating that tracking is currently not enabled, therefore no Contact is present and there is no Interaction between the site and user.
Therefore you need to start Sitecore.Tracker I recommend using the following code
if (!Tracker.IsActive)
Tracker.StartTracking();
if (!Tracker.IsActive || Tracker.Current.Contact == null)
{
// handle no tracker and contact
}
Now that you have tracking working you need to use the correct ID for your sessionID variable.
The blog you are following is based on Sitecore 7, in Sitecore 8 Sitecore.Form.Core.Analytics.AnalyticsTracker.SessionId is removed. I decompiled the Sitecore 7 code and Sitecore.Form.Core.Analytics.AnalyticsTracker.SessionId ultimately uses Tracker.CurrentVisit.VisitId.
However this namespace has changed in Sitecore 8, Visits are now called interactions so instead of your variable SessionID you will want to use
Tracker.Current.Interaction.InteractionId;
That should resolve the issue you are currently having but you may need a bit more development to finish it off.

Sitecore ECM 2.1: Is there a way to segment the users based on a condition?

Is there any way to send mails to certain users based on a condition in ECM 2.1 . For example, I want to send mails to only those users whose user profile property Country='USA'. Is there a way to do this in ECM 2.1?
Earlier for ECM 1.3 we used to use a third party segmentation module below
https://marketplace.sitecore.net/en/Modules/Sitecore_EmailCampaign_Segment.aspx
But it does not support ECM 2.1. So I was wondering how to implement it in ECM 2.1 . By the way we are using Sitecore 7.2
If you don't mind extending ECM slightly you could tap into the DispatchNewsletter Pipline.
If you add processor like the following, you could get all the users dynamically and add them to the subscribers list. You just need to make sure that this only fires on certain scenarios to avoid this interfering with the core product functionality.
public class GetUSASubscribers
{
public void Process(DispatchNewsletterArgs args)
{
if(CanProcessEmail(args))
{
var matches = UserManager.GetUsers().Where(usr => usr.Profile["Country"].Equals("USA")).ToList();
foreach (var username in matches)
{
if (User.Exists(username.Name))
{
var contact = Contact.FromName(username.LocalName);
args.Message.Subscribers.Add(contact);
args.Message.SubscribersNames.Add(contact.Name);
}
}
}
}
}
You can register the processor as follows in your Sitecore.EmailCampaign.config
<DispatchNewsletter>
<processor type="Sitecore.Modules.EmailCampaign.Core.Pipelines.DispatchNewsletter.CheckPreconditions, Sitecore.EmailCampaign" />
<processor type="YourClass, YourNamespace" />
........................
</DispatchNewsletter>
To make it more dynamic you could add a Rules engine field to each message item to determine which users are added to the subscriber list. So the logic e.g where user profile["country"] equals 'USA' could be in the rules field.
For reference, some more detail on the set up of rules in Sitecore.
http://blog.horizontalintegration.com/2013/12/06/bending-the-sitecore-rules-field-to-your-will-with-sitecore-7-1-part-1/