Renumbering topic Context ID values using HelpNDoc API - helpndoc

I have found this tutorial for exporting context help ID values to a data file:
const
// Define the output file
OUTPUT_FILE = 'c:\tmp\topics.txt';
var
// Current topic ID
aTopicId: string;
// List of output
aList: TStringList;
begin
// Init list
aList := TStringList.Create;
aList.Add('Topic Caption | Help ID | Help Context');
aList.Add('--------------------------------------');
try
// Get first topic
aTopicId := HndTopics.GetTopicFirst();
// Loop through all topics
while aTopicId <> '' do
begin
// Add the topic to the list
aList.Add(Format('%s | %s | %d', [
HndTopics.GetTopicCaption(aTopicId),
HndTopics.GetTopicHelpId(aTopicId),
HndTopics.GetTopicHelpContext(aTopicId)
]));
// Get next topic
aTopicId := HndTopics.GetTopicNext(aTopicId);
end;
// Create the file
aList.SaveToFile(OUTPUT_FILE);
finally
aList.Free;
end;
end.
I have done some re-structuring of my revised help documentation and as a result the context numbers are not sequential:
Using HelpNDoc I was hoping to write a new API script to renumber them but I can't see a suitable API method.
Is this not possible?

Using HelpNDoc API, you can change the help context number of a topic using the HndTopics.SetTopicHelpContext method call. Using simple logic, it is possible to reset all help context numbers. This is described in the following article: Using HelpNDoc scripting capabilities to automatically reset all help context numbers
The script showcased in the article is even included in recent HelpNDoc's installation folder:
Context numbers can become messy as HelpNDoc project evolves. This script will reset each topic's context number so that they are setup incrementally from first topic till last one.
Here is how to run that script:
Save a backup of your project in case your need to go back
Load your project
From HelpNDoc's "Tools" ribbon tab, click "Script Editor"
Click the arrow next to "Load script" to display the list of built-in scripts
Click "ResetHelpContextNumbers.hnd.pas"
Click "Run script"

Related

SubmitForm then Patch results in "The data returned by the service was invalid"

I'm building a PowerApps app on Azure SQL
The requirement
I have a form which has "Save" and "Confirm" buttons.
Both buttons should save the form data. The Commit button should also set database column "Confirm" to 1
I've read at length about how I can programatically override the update value of a hidden control for this. But I'm not satisfied with the level of complexity (maintenance) required to get this working, i.e.
Populate a variable with the current db value
In the button code set the variable value
In the form field, set the update property to the variable
What I'm Trying
So I'm trying a different approach: SubmitForm then Patch. Even though this requires an extra database call, I'd like to understand if this will work. This is the code for OnSelect in the commit button:
// Save the record
SubmitForm(frmEdit);
// Update confirmed to 1
Patch('[dbo].[Comments]',cRecord,{Confirmed:1});
Some Complexities
Note that my record is a variable, cRecord. In short I want this app to be able to upsert based on URL parameters.
This is my App.OnStart which captures URL values, inserts a record if required. Regardless, the result of this event is that cRecord is set to the record to be edited.
// Cache employees and store lookups (as they are in a different db)
Concurrent(Collect(cEmployees, Filter('[dbo].[SalesPerson]', Status = "A")),Collect(cStores, '[dbo].[Store]'));
// Check for parameters in the URL. If found, set to Edit/Add mode
Set(bURLRecord,If((!IsBlank(Param("PersonId")) && !IsBlank(Param("Date"))),true,false));
// If URL Parameters were passed, create the record if it doesn't exist
If(bURLRecord,
Set(pPersonId,Value(Param("PersonId")));
Set(pDate,DateValue(Param("Date")));
// Try and find the record
Set(cRecord,LookUp('[dbo].[Comments]',SalesPersonId=pPersonId && TransactionDate = pDate));
If(IsBlank(cRecord),
// If the record doesn't exist, create it with Patch and capture the resulting record
Set(cRecord,Patch('[dbo].[Comments]',Defaults('[dbo].[Comments]'),{SalesPersonId:pPersonId,TransactionDate:pDate}))
);
// Navigate to the data entry screen. This screen uses cRecord as its item
Navigate(scrEdit);
)
frmEdit.Item is set to cRecord. As an aside I also have a gallery that sets this variable value when clicked so we can also navigate here from a gallery.
The navigating using new and existing URL parameters works. Navigating from the gallery works.
The problem
When I press the Commit button against a record which has Confirmed=0 I get this popup error:
The data returned by the service is invalid
When I run this code against a record which already has Confirmed=1 I don't get an error
If I run the PowerApps monitor it doesn't show any errors but it does show some counts being run after the update. I can paste it here if required.
I also tried wrapping the Path in a Set in case it's result was confusing the button event but it didn't make a difference.
What I want
So can anyone offer me any of the following info:
How can I get more info about "The data returned by the service is invalid"?
How can I get this to run without erroring?
Is there a simpler way to do the initial upsert? I was hoping a function called Patch could upsert in one call but it seems it can't
With regards to the setting field beforehand approach, I'm happy to try this again but I had some issues implementing it - understanding which control where to edit.
Any assistance appreciated.
Edit
As per recommendations in the answer, I moved the patch code into OnSuccess
If(Confirmed=1,Patch('[dbo].[CoachingComments]',cRecord,{Confirmed:1}));
But now I get the same error there. Worse I cleared out OnSucces and just put SubmitForm(frmEdit); into the OnSelect event and it is saving data but still saying
The data returned by the service was invalid
First things first,
Refactoring has multiple steps,
I can t type all out at once...
The submitform and patch issue:
Never use the submitforn with extra conplexity
Submitform is only the trigger to send the form out,
The form handler will work with your data...
If you hsven t filled out the form correctly, u don t want to trigger your patch action...
So:
On your form, you have an OnSucces property,
Place your patch code there...
Change your cRecord in your patch statement:
YourForm.LastSubmit

Variable does not save event.response from network.request -Lua

I am trying to create a Lua program using Sublime and Corona. I want to fetch a webpage, use a pattern to extract certain text from the page, and then save the extracted text into a table. I am using the network.request method provided by Corona
The problem: The extracted text is not saving into the global variable I created. Whenever I try to reference it or print it outside of the function it returns nil. Any ideas why this is happening?
I have attached a screen shot of my event.response output. This is what I want to be saved into my Lua table
Event.response Output
Here is my code:
local restaurants = {}
yelpString = ""
--this method tells the program what to do once the website is retrieved
local function networkListener( event )
if ( event.isError ) then
print( "Network error: ", event.response )
else
yelpString = event.response
--loops through the website to find the pattern that extracts
restaurant names and prints it out
for i in string.gmatch(yelpString, "<span >(.-)<") do
table.insert(restaurants, i)
print(i)
end
end
end
-- retrieves the website
network.request( "https://www.yelp.com/search?
cflt=restaurants&find_loc=Cleveland%2C+OH%2C+US", "GET", networkListener )
This sounds like a scoping problem. From the output you give, it looks like networkListener is being called, and you are successfully adding the text into the restaurants table. Moreover, since you define restaurants as a table, it should be a table when you reference it, not nil. So by deduction, the issue must be that you are trying to access the restaurants table from somewhere where it is not in scope.
If you declare restaurants as "local" in the top level of a file (i.e. not within a function or a block), it will be accessible to the whole file, but it won't be accessible to anything outside the file. So the table.insert(restaurants, i) in your code will work, but if you try to reference restaurants from somewhere outside the file, it will be nil. I'm guessing this is the cause of the problems that you are running into.
For more details on scope, have a look at the Programming in Lua book. The book is for Lua 5.0, but the scoping rules for local variables have not changed in later versions of Lua (as of this writing, the latest is Lua 5.3).

Send current Login name to apex item

I want to assign current login username into an apex 5.0 item, how can i do it.
I did below but it is not working.
dynamic action = 'on page load' action = set value Set Type = Static Asisgnment Value = &APP_USER; also :APP_USER. Affected Elements = :P12_USERNAME;
Values like this can be baked into the page render, no dynamic action necessary. Though I suspect your problem was all you needed to supply for affected elements was the item name, no punctuation.
If you want to assign it as a default value just on the UI item, then use the 'Default' option, below source details. Use Static Value:
&APP_USER.
If you need the value to also be in session state, then use a 'before region' computation on the item, but it only needs to be the same static value.
If you're not sure what session state is, then please read the concepts manual, then read a few blogs and presentations on that specific topic.
http://docs.oracle.com/cd/E59726_01/doc.50/e39147/concept.htm#HTMDB03000
If you ever need to refer to it within PL/SQL, don't use substitution strings, this opens your application to SQL Injection security issues. Use this instead:
:P12_ID := :APP_USER;
There are a list of built in substutition strings here
http://docs.oracle.com/cd/E59726_01/doc.50/e39147/concept_sub.htm#HTMDB25032
with following code i solved my problem.
1: create a PROCESS and set the EXECUTION POINT to AFTER HEADER, selected process TYPE to PL/SQL, with the below code.
Declare
username varchar2(20) := '&APP_USER.';
BEGIN
:P12_ID := username;
END;

Adding quick link on admin home page (Prestashop 1.5.4)

Good day! Tell me, how can I add a quick link on the home page of the administrator to configure my module?
Follow the following steps:
1) In admin section to go Administration at top menu and then click on Quick Access.
2) IN next page click on Add new and you will see a form
3) Now open admin panel in another tab and to the module page or section, of which you want to place a link in quick access.
4) Copy that complete link in note pad and remove the token section of the link. It is required to remove the token section according to Prestashop.
5) Now come back to the add new form for quick access, give your link a name and then copy that modified link to the Url field.
6) Save it and you will have that link in quick access.
The above is method is used to add it at admin. Now if you want to add it pro-grammatically you can follow the following steps.
1) In your module in the install function, user a code like below
Db::getInstance()->insert('quick_access', array('new_window' => 0, 'link' => 'link_to_your_module_page'));
//an entry is made in quick_access table, get the quick_access id to insert lang data
$id = Db::getInstance()->Insert_ID(); //this will give you last inserted ID from quick_access table which is your current quick_access id.
//now make insertions in quick_access_lang table for multi language data.
//get all your site languages, and place a foreach loop and in that loop insert
//data into the quick_access_lang table using below code
Db::getInstance()->insert('quick_access_lang', array('id_quick_access' => $id, 'id_lang' => 'lang_id', 'name' => 'name of your link'));
//Now for uninstalling module, you want to delete the link, so you need to store the quick access link id in configuration table so you can use it later.
Configuration::updateValue('MY_QUICK_ACCESS_LINK_ID', $id);
2) Now in your uninstall function in your module class, place the below code
$id = Configuration::get('MY_QUICK_ACCESS_LINK_ID'); //get id of your quick access link
Db::getInstance()->delete('quick_access', 'where id_quick_access = '.$id);
Db::getInstance()->delete('quick_access_lang', 'where id_quick_access = '.$id);
//now delete the id from config table
Configuration::deleteByName('MY_QUICK_ACCESS_LINK_ID');
Note : The above code is not tested, it may / may not need some adjustments.
Thank you
There is a hook in Prestashop DisplayAdminHomeQuickLinks it will help you to add quick link on prestashop admin panel. I have use this in my theme. http://goo.gl/0S3mn And it will help you to solve the quick link.
In Prestashop 1.6.1 (maybe earlier too) in Admin view, at the top of the page, Quick Access has the option to "Add current page to QuickAccess". So just navigate to the Configuration page you need and use it.

How to update report in Dynamic NAV using RDLC report?

How can i write a function to update record in Microsoft Dynamic NAV using Role Tailored Client Report ?
Thx in advance,
Makara
You can place code in your report triggers.
Below is a simple example of code that can be put in the OnAfterGetRecord trigger of a Customer data item that refers to the Customer table.
IF Customer.Name[1] = 'A' THEN BEGIN
Customer.Name[1] := 'B';
Customer.MODIFY;
END
The code above changes the first character of the name of any customer included in the report that begins with an upper case 'A' to an upper case 'B'.
A complete report with just this functionality and no printout can be found from pastebin:
Simple Dynamics Nav Report Sample.
You can copy the entire content of the paste into a text file and import it into Nav as text.
Beware, however that doing this will replace any previous report with the id of 50000 with this example without any additional warning or prompt. The report imported as text will need to be saved in compiled form in Nav prior to you being able to run it.
You cannot place C/AL code directly on RTC Reports -- instead you should use the triggers behind DataItems in the 'Classic' client/Development Environment, as this code is common to both Classic and RTC reports, and executed when the report is run in either environment.
To use a similar example;
Vendor - OnAfterGetRecord()
----------------------------
...
IF Vendor."Phone No." = '' THEN BEGIN
Vendor."Phone No." := NewPhoneNo;
Vendor.MODIFY;
END;
...
You may want to set the following properties on the report itself to hide the print dialog, as well as the request form (assuming you don't want filters applied):
UseReqForm := FALSE;
ProcessingOnly := TRUE;
Another important thing to note is that code sitting behind sections is only used for Classic reports and won't be executed if running in the RTC (which may explain unexpected results).