1

I am planning of writing a plugin on the topic update, and retrieve the list of all the references where a particular topic is being used. Please help me with some guidance.

2
1

You need to be using the Content Manager web services API in Docs to be able to retrieve the references for a topic. The documentation of an example web service call is here.

The web service class you are looking for is the Reports class which contains the method GetReferencesByIshLngRef. This method is synonymous with Where Used and will return where a specific topic is referenced.

So in your application, you would add a service reference to the Reports service. The URL would be the web service URL followed by /Wcf/API20/reports.svc and for the namespace give something like ReportsClientServiceReference. For example, https://docs.sdldemo.com/ISHWS/Wcf/API20/reports.svc. Visual Studio would then generate the necessary classes and update the .config appropriately. You should be able to now call the method GetReferencesByIshLngRef.

The following example code should get the list of items referenced by a topic.

var ishWSUri = new Uri(@"https://docs.sdldemo.com/ISHWS/");
var ishWSBinding = new CustomBinding("CustomBinding_Application1");
var reportsUri = new Uri(ishWSUri, "Wcf/API20/Reports.svc");
var issuerUri = new Uri(@"https://docs.sdldemo.com/ISHSTS/issue/wstrust/mixed/username");
var credential = new NetworkCredential("<user name>", "<password>");
var authenticationType = enAuthenticationType.UsernameMixed;
var token = IssueToken(issuerUri, authenticationType, credential, ishWSUri);

var reportsClient = new ReportsClientServiceReference.ReportsClient(ishWSBinding, new EndpointAddress(reportsUri));
var reportsChannel = reportsClient.ChannelFactory.CreateChannelWithIssuedToken(token);

ReportsClientServiceReference.GetReferencesByIshLngRefRequest inValue = new ReportsClientServiceReference.GetReferencesByIshLngRefRequest();
string xmlExtObjectList = "<ishfields>" +
                          "  <ishfield name='VERSION' level='version'/>" +
                          "  <ishfield name='DOC-LANGUAGE' level='lng'/>" +
                          "  <ishfield name='FTITLE' level='logical'/>" 
                          "</ishfields>";
             
// The ID of the topic at the language level. This can also be a comma-seperated list.
inValue.lngRefs = "11689";
inValue.xmlExtObjectList = xmlExtObjectList;                        

ReportsClientServiceReference.GetReferencesByIshLngRefResponse references  = reports20Channel.GetReferencesByIshLngRef(inValue);
String returnValue = references.returnValue;

// xmlOutput contains all Docs objects referenced by a topic.
String xmlOutput = references.xmlExtObjectList;
3
  • Thank you Sabarish. Actually I am aware of the content manager web services, but I need to perform this activity on a topic update. So thought plugin will be right way to achieve this requirement. On topic update we need to find the references and need to update the latest version of the topic in there. Please suggest how can we achieve this using Write plugins. Nov 19 at 4:53
  • Write plugins would not contain any methods to get topic references. In the write plugin handler, you would have to make a call to the CM web services API to get topic references. Or you can create a REST service on top of the CM web service that returns topic references and call that in the handler. Nov 19 at 5:49
  • Hi Sabarish.. You are correct, there are no such methods present in plugin. We need to use CM web Api to perform that task. I am marking your answer as answer to the question as there is no other go. Thank you. Dec 1 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.